:root {
  --bg: #fff7ef;
  --bg-soft: #fdeede;
  --card: #ffffff;
  --text: #4a3f35;
  --text-soft: #8a7a6b;
  --accent: #f6a96b;
  --accent-deep: #e8893f;
  --good: #6fae8f;
  --line: #f0e3d6;
  --shadow: 0 6px 22px rgba(180, 130, 80, 0.14);
}
html[data-theme="dark"] {
  --bg: #1e1a17;
  --bg-soft: #2a241f;
  --card: #2c261f;
  --text: #f1e7db;
  --text-soft: #b29e8a;
  --accent: #f6a96b;
  --accent-deep: #e8893f;
  --good: #6fae8f;
  --line: #3a332b;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.topbar {
  padding: 18px 20px 10px;
  text-align: center;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.brand .en { font-size: 12px; color: var(--accent-deep); font-weight: 600; margin-left: 4px; }
.view { flex: 1; padding: 8px 18px 24px; overflow-y: auto; }
.tabbar {
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 13px;
  padding: 8px 0;
  cursor: pointer;
}
.tab.active { color: var(--accent-deep); font-weight: 700; }

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.section-title { font-size: 15px; font-weight: 700; margin: 4px 0 12px; }
.muted { color: var(--text-soft); font-size: 13px; }

.affirm {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.7;
  color: var(--text);
}
.streak-num { font-size: 38px; font-weight: 800; color: var(--accent-deep); }
.mood-row { display: flex; gap: 8px; margin: 10px 0; }
.mood-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 10px 0;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.mood-btn.sel { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 700; }
textarea, input[type="text"], input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-soft);
  color: var(--text);
  resize: vertical;
}
.btn {
  display: inline-block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-top: 10px;
}
.btn.ghost { background: var(--bg-soft); color: var(--text); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--text-soft);
}
.cal-cell.done { background: var(--accent); color: #fff; font-weight: 700; }
.cal-cell.today { outline: 2px solid var(--accent-deep); }
.cal-head { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: 11px; color: var(--text-soft); }
.entry {
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 0 12px 12px 0;
  margin-bottom: 10px;
}
.entry .meta { font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.entry .del { float: right; color: var(--text-soft); cursor: pointer; font-size: 12px; }
.locked { color: var(--text-soft); font-style: italic; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  z-index: 99;
}
.toast.show { opacity: .92; }
.hotline { font-size: 13px; line-height: 1.9; }
.hotline b { color: var(--accent-deep); }

/* ---- Guardian modal ---- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(40, 30, 20, 0.45); }
.modal-card {
  position: relative;
  width: calc(100% - 40px);
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  z-index: 1;
}
.modal-close {
  position: absolute; top: 10px; right: 12px;
  border: none; background: none; font-size: 26px; line-height: 1;
  color: var(--text-soft); cursor: pointer;
}
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.reward-grid { display: flex; gap: 14px; margin-top: 14px; }
.reward-col { flex: 1; text-align: center; }
.reward-name { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.reward-img {
  width: 100%; max-width: 160px; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 14px; border: 1px solid var(--line); background: var(--bg-soft);
}
.reward-ph {
  width: 100%; max-width: 160px; aspect-ratio: 3 / 4; margin: 0 auto;
  border: 1px dashed var(--accent); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-size: 13px; line-height: 1.6;
  background: var(--bg-soft);
}
code { background: var(--bg-soft); padding: 1px 5px; border-radius: 6px; font-size: 12px; }
