/* 我们的小日子 —— 样式 */
:root {
  --bg: #fdf7f3;
  --bg-2: #fffdfb;
  --ink: #3a2e2a;
  --ink-2: #7b6a63;
  --ink-3: #a8968e;
  --line: #ecdcd3;
  --rose: #d9736b;
  --rose-2: #c25a52;
  --rose-soft: #fbe9e6;
  --card: #ffffff;
  --shadow: 0 2px 8px rgba(120, 80, 60, 0.06), 0 12px 32px rgba(120, 80, 60, 0.07);
  --radius: 18px;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1512;
    --bg-2: #241b17;
    --ink: #f2e8e2;
    --ink-2: #b8a49a;
    --ink-3: #8a7770;
    --line: #3a2c26;
    --rose: #e58a80;
    --rose-2: #d1736a;
    --rose-soft: #33221f;
    --card: #241b17;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.28);
  }
}

/* 手动切换的深色（覆盖系统设置） */
:root[data-theme="dark"] {
  --bg: #1b1512;
  --bg-2: #241b17;
  --ink: #f2e8e2;
  --ink-2: #b8a49a;
  --ink-3: #8a7770;
  --line: #3a2c26;
  --rose: #e58a80;
  --rose-2: #d1736a;
  --rose-soft: #33221f;
  --card: #241b17;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.28);
}

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

/* hidden 属性必须真的隐藏。下面 .gate/.modal 等都设了 display，
   会盖掉浏览器默认的 [hidden]{display:none}，所以这里强制一次。 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.muted {
  color: var(--ink-2);
}

.err {
  color: var(--rose-2);
  font-size: 13px;
  margin: 8px 0 0;
  min-height: 18px;
}

/* ── 登录门 ─────────────────────────────────────────── */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #fdf7f3 0%, #fbeae6 60%, #f7dcd6 100%);
  z-index: 100;
}
.gate-card {
  width: 100%;
  max-width: 320px;
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.gate-heart {
  font-size: 34px;
  color: var(--rose);
  line-height: 1;
  animation: beat 1.6s ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1); }
}
.gate-card h1 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 14px 0 4px;
}
.gate-card input {
  width: 100%;
  margin: 18px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  outline: none;
}
.gate-card input:focus {
  border-color: var(--rose);
}
.gate-card .btn {
  width: 100%;
}

/* ── 顶部 ───────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 34px 20px 30px;
  text-align: center;
  background: linear-gradient(170deg, #fff9f6 0%, #fdeee9 55%, #fbe4de 100%);
  border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero {
    background: linear-gradient(170deg, #241b17 0%, #2c1f1a 55%, #33221f 100%);
  }
}
.hero-inner {
  position: relative;
  z-index: 2;
}
.hero-glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 115, 107, 0.22), transparent 70%);
  top: -160px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
}
.hero-sub {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  text-transform: uppercase;
}
.hero-title {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  margin: 6px 0 0;
  letter-spacing: 0.04em;
}
.counter {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 10px 0 2px;
}
.counter-num {
  font-family: var(--serif);
  font-size: 52px;
  line-height: 1;
  font-weight: 600;
  color: var(--rose);
  font-variant-numeric: tabular-nums;
}
.counter-unit {
  font-size: 15px;
  color: var(--ink-2);
}

/* ── 工具条 ─────────────────────────────────────────── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 40px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-3);
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
}
.search input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* ── 按钮 ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--bg-2);
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s;
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--rose);
  color: #fff;
  box-shadow: 0 4px 14px rgba(217, 115, 107, 0.32);
}
.btn.primary:hover {
  background: var(--rose-2);
}
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-2);
}
.btn.ghost:hover {
  background: var(--rose-soft);
  color: var(--rose-2);
}
.btn.danger.ghost {
  border-color: var(--rose);
  color: var(--rose);
}
.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover {
  background: var(--rose-soft);
  color: var(--rose-2);
}
.text-btn {
  border: 0;
  background: none;
  color: var(--rose);
  font-size: 13px;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: none;
}
.text-btn:hover {
  text-decoration: underline;
}

/* ── 时间轴 ─────────────────────────────────────────── */
.timeline {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px 30px;
}

.month {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 12px;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 0.08em;
}
.month::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.month:first-child {
  margin-top: 4px;
}

.entry {
  position: relative;
  display: flex;
  gap: 13px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: rise 0.34s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.entry:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(120, 80, 60, 0.1), 0 16px 40px rgba(120, 80, 60, 0.1);
}
.entry:active {
  transform: scale(0.995);
}

.entry-day {
  flex: 0 0 46px;
  text-align: center;
  color: var(--ink-3);
  font-size: 11px;
  padding-top: 2px;
}
.entry-day b {
  display: block;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.15;
  color: var(--ink);
  font-weight: 600;
}

.entry-photo {
  flex: 0 0 88px;
  height: 88px;
  border-radius: 13px;
  overflow: hidden;
  background: var(--rose-soft);
}
.entry-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.entry-main {
  flex: 1;
  min-width: 0;
}
.entry-title {
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-text {
  font-size: 13.5px;
  color: var(--ink-2);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--ink-3);
}
.entry-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.entry-mood {
  font-size: 15px;
  line-height: 1;
  position: absolute;
  top: 12px;
  right: 14px;
}

/* ── 空状态 / 页脚 ──────────────────────────────────── */
.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-2);
}
.empty-emoji {
  font-size: 44px;
  margin-bottom: 12px;
  animation: sway 3s ease-in-out infinite;
}
@keyframes sway {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
.foot {
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  padding: 10px 20px 40px;
}

/* ── 弹层 ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(30, 18, 14, 0.42);
  backdrop-filter: blur(3px);
  animation: fade 0.18s ease;
  padding: 0;
}
@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: 20px;
  }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.24s cubic-bezier(0.22, 0.8, 0.3, 1) both;
  overflow: hidden;
}
@media (min-width: 640px) {
  .modal-card {
    border-radius: 22px;
  }
  @keyframes slideUp {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to { opacity: 1; transform: none; }
  }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}
.modal-head h2 {
  font-family: var(--serif);
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}
.modal-body {
  padding: 4px 18px 8px;
  overflow-y: auto;
  flex: 1;
}
.draft-hint {
  margin: 8px 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--rose-soft);
  color: var(--ink-2);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}
.draft-hint[hidden] {
  display: none;
}
.draft-hint .text-btn {
  font-size: 12.5px;
  padding: 0 2px;
}
.modal-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.spacer {
  flex: 1;
}

/* 照片选择 */
.photo-pick {
  display: block;
  cursor: pointer;
}
.photo-preview {
  height: 168px;
  border-radius: 14px;
  border: 1.5px dashed var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
  transition: border-color 0.15s;
}
.photo-pick:hover .photo-preview {
  border-color: var(--rose);
}
.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 13px;
}

/* 表单 */
.field {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  outline: none;
  margin-top: 10px;
  transition: border-color 0.15s;
}
.field:focus {
  border-color: var(--rose);
}
.field.big {
  font-size: 16px;
  font-weight: 500;
}
.field.area {
  resize: vertical;
  min-height: 88px;
  line-height: 1.6;
}
.row {
  display: flex;
  gap: 10px;
}
.row > * {
  flex: 1;
  min-width: 0;
}
.label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 14px;
}
.modal-card.small .modal-body {
  padding-bottom: 20px;
}

/* 心情 */
.moods {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.mood {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 19px;
  cursor: pointer;
  transition: all 0.14s;
  display: grid;
  place-items: center;
  padding: 0;
}
.mood:hover {
  border-color: var(--rose);
}
.mood.on {
  background: var(--rose-soft);
  border-color: var(--rose);
  transform: scale(1.06);
}

/* ── 提示 ───────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: rgba(40, 26, 22, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 200;
  animation: toastIn 0.22s ease;
  max-width: 84vw;
  text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── 大图查看 ───────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10, 6, 4, 0.94);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.16s ease;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}
