/* 托育小记 — 移动优先,暖色系,容器 ≤520px,触控目标 ≥44px */
:root {
  --bg: #FFF9F2;
  --card: #FFFFFF;
  --text: #4A3F35;
  --muted: #A2958A;
  --accent: #FF8A5C;
  --border: #F0E6DA;
  --shadow: 0 2px 10px rgba(120, 90, 60, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
body.no-scroll { overflow: hidden; }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

/* ── 顶栏 ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-spacer { width: 44px; }

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
}

/* 同步状态点 */
.sync-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  padding: 0;
  margin: 15px;
  cursor: pointer;
}
.sync-dot.gray { background: #C9C0B8; }
.sync-dot.green { background: #5FB760; }
.sync-dot.yellow { background: #F5A623; animation: pulse 1.4s ease-in-out infinite; }
.sync-dot.red { background: #E53935; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ── 缺卡提醒 ── */
.miss-banner {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 4px 0 10px;
  font-size: 15px;
  cursor: pointer;
  background: #FFF3EC;
}

/* ── 月度统计 ── */
.month-stats {
  color: var(--muted);
  font-size: 14px;
  margin: 2px 2px 10px;
  min-height: 21px;
}

/* ── 日历 ── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title { font-size: 17px; font-weight: 600; }
.nav-btn {
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
}
.today-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.cal-weekdays .weekend { color: #D5C9BC; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.day {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  user-select: none;
}
.day.empty { background: none; box-shadow: none; cursor: default; }
.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day.weekend .day-num { color: var(--muted); }
.day.has-status { background: var(--c); }
.day.has-status .day-num { color: #FFFFFF; font-weight: 600; }
.day-num { font-size: 15px; }
.holiday-label {
  font-size: 9px;
  color: #E53935;
  line-height: 1;
  transform: scale(0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
}
.day.has-status .holiday-label { color: rgba(255, 255, 255, 0.95); }
.note-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.day.has-status .note-dot { background: rgba(255, 255, 255, 0.9); }

/* ── 卡片(设置页) ── */
.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 14px 0;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }

.field {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
}
.field input {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  color: var(--text);
  background: #FFFDFA;
}
.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 15px;
}
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn-row { display: flex; gap: 10px; margin: 8px 0; }
.btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.5; }
.muted { color: var(--muted); font-size: 13px; }

/* ── 状态类型管理 ── */
.type-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
}
.type-row:last-child { border-bottom: none; }
.type-dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.type-label { flex: 1; font-size: 15px; }
.type-builtin { font-size: 12px; color: var(--muted); }
.type-edit { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; width: 100%; }
.type-edit input[type="text"] {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}

.color-row { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 0; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  padding: 0;
  cursor: pointer;
  background: var(--c);
}
.swatch.sel { border-color: var(--text); }

.add-type { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.add-type input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #FFFDFA;
}

/* ── 底部弹层:当天详情 ── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(60, 45, 30, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp { from { transform: translateY(30%); opacity: 0.6; } }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 10px;
}

.status-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.status-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  border: 2px solid var(--c);
  background: var(--card);
  color: var(--c);
  font-size: 15px;
  cursor: pointer;
}
.status-btn.active { background: var(--c); color: #fff; }

#noteInput {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
}
.save-hint { min-height: 20px; margin-top: 6px; text-align: right; }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 86vw;
  background: rgba(50, 40, 32, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 200;
}
.toast[hidden] { display: none; }
