:root {
  --bg: #FFF6EC;
  --card: #FFFFFF;
  --accent: #FF6B6B;
  --accent-2: #FFA502;
  --text: #2D2A32;
  --muted: #8A8590;
  --line: #EFE9E2;
  --danger: #E5484D;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(93, 62, 36, 0.08);
}

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

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #FFF7EF 0%, #FFE9D6 100%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-user-select: none;
  user-select: none;
}

/* ===== 视图切换 ===== */
.view { display: none; padding: 20px 16px; max-width: 520px; margin: 0 auto; }
.view.active { display: block; }

.page-header h1 { font-size: 26px; margin: 6px 0 0; }
.page-header .subtitle { color: var(--muted); margin: 6px 0 0; font-size: 14px; }

/* ===== 转盘 ===== */
.wheel-wrap { position: relative; width: 100%; max-width: 360px; margin: 20px auto 0; }
.wheel-wrap canvas { display: block; width: 100%; }

.pointer {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 3;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid var(--accent);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

.spin-btn {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 68px; height: 68px; border-radius: 50%;
  border: 4px solid #fff; background: var(--accent);
  color: #fff; font-size: 16px; font-weight: 800; letter-spacing: 2px;
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.5);
  z-index: 4; cursor: pointer; padding: 0;
}
.spin-btn:active { transform: translate(-50%, -50%) scale(0.94); }
.spin-btn:disabled { opacity: 0.7; }

#wheelHint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; line-height: 1.6; }

/* ===== 活动 ===== */
.add-row { display: flex; gap: 10px; margin: 14px 0 4px; }
.add-row input {
  flex: 1; min-width: 0; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 14px;
  font-size: 16px; background: #fff; color: var(--text);
}
.add-row button {
  padding: 0 20px; border: none; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
}
section h2 { font-size: 14px; color: var(--muted); margin: 24px 0 8px; font-weight: 700; }
.count { color: var(--accent); }
ul { list-style: none; padding: 0; margin: 0; }
li {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 8px; box-shadow: var(--shadow);
}
li span { flex: 1; font-size: 15px; word-break: break-all; }
li.empty { color: var(--muted); justify-content: center; font-size: 13px; box-shadow: none; background: transparent; }

.mini {
  border: none; border-radius: 10px; padding: 7px 12px;
  font-size: 13px; font-weight: 700; background: #FFF0E8; color: var(--accent);
  white-space: nowrap;
}
.mini.danger { background: #FDEAEA; color: var(--danger); }

.backup { margin-top: 28px; display: flex; gap: 10px; }
.backup button {
  flex: 1; padding: 11px; border: none; border-radius: 12px;
  background: #fff; color: var(--muted); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow);
}

/* ===== 月历 ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 8px; }
.cal-head button {
  width: 42px; height: 42px; border: none; border-radius: 12px;
  background: #fff; font-size: 24px; color: var(--accent); box-shadow: var(--shadow);
}
#calTitle { font-size: 19px; font-weight: 800; }
.today-btn {
  border: none; background: #fff; color: var(--accent); font-weight: 700;
  font-size: 13px; padding: 7px 14px; border-radius: 20px; box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays div { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; }
.day {
  background: #fff; border-radius: 12px; min-height: 62px; padding: 5px;
  box-shadow: 0 2px 8px rgba(93, 62, 36, 0.06);
}
.day-num { font-size: 13px; color: var(--text); display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
.day.today .day-num { background: var(--accent); color: #fff; border-radius: 50%; }
.day-chip {
  margin-top: 3px; font-size: 11px; line-height: 1.25; color: #fff;
  background: linear-gradient(135deg, #FF6B6B, #FFA502);
  border-radius: 7px; padding: 2px 4px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  word-break: break-all;
}
.day.has-draw { cursor: pointer; }
.cal-tip { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}
.tab { flex: 1; background: none; border: none; font-size: 14px; color: var(--muted); padding: 8px 0; font-weight: 700; }
.tab.active { color: var(--accent); }

/* ===== 覆盖层 ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
}
.overlay.center { align-items: center; }
.overlay.hidden { display: none; }

.sheet {
  background: #fff; width: 100%; max-width: 520px;
  border-radius: 24px 24px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
#detailDate { color: var(--muted); font-size: 13px; font-weight: 600; }
#detailClose { border: none; background: #f2f2f2; width: 32px; height: 32px; border-radius: 50%; font-size: 15px; color: var(--text); }

.pinned {
  margin: 14px 0 4px; font-size: 23px; font-weight: 800; text-align: center;
  padding: 20px 12px; background: linear-gradient(135deg, #FF6B6B, #FFA502);
  color: #fff; border-radius: 16px; box-shadow: var(--shadow); word-break: break-all;
}
.diary-label { display: block; margin: 16px 0 6px; font-size: 14px; color: var(--muted); font-weight: 700; }
#diaryText {
  width: 100%; min-height: 120px; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px; font-size: 16px; resize: vertical; font-family: inherit; color: var(--text);
}
.photo-add {
  display: inline-block; padding: 10px 18px; background: #FFF0E8; color: var(--accent);
  border-radius: 12px; font-weight: 700; font-size: 14px; margin-top: 14px; cursor: pointer;
}
.photo-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-item { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #f2f2f2; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 12px; line-height: 1;
}
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions button { flex: 1; padding: 13px; border: none; border-radius: 14px; font-size: 15px; font-weight: 800; }
#reAddBtn { background: #FFF0E8; color: var(--accent); }
#deleteDrawBtn { background: #FDEAEA; color: var(--danger); }

.result-card { background: #fff; border-radius: 24px; padding: 28px 24px; width: 86%; max-width: 340px; text-align: center; }
.result-label { color: var(--muted); font-size: 15px; }
.result-name { font-size: 26px; font-weight: 800; margin: 10px 0 22px; word-break: break-all; }
.result-actions { display: flex; gap: 10px; }
.result-actions button { flex: 1; padding: 13px; border: none; border-radius: 14px; font-size: 15px; font-weight: 800; }
#resultWriteBtn { background: var(--accent); color: #fff; }
#resultCloseBtn { background: #f2f2f2; color: var(--text); }

.lightbox { background: rgba(0, 0, 0, 0.85); }
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.82); color: #fff; padding: 10px 18px;
  border-radius: 22px; font-size: 14px; opacity: 0; transition: 0.25s;
  z-index: 200; pointer-events: none; max-width: 82%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
