:root {
  --bg: #f3f7f4;
  --bg2: #eaf3ee;
  --card: #ffffff;
  --ink: #4a5b53;
  --ink-soft: #8aa093;
  --mint: #7fc8a9;
  --mint-deep: #5bb394;
  --peach: #ffd9b3;
  --pink: #ffb3c1;
  --shadow: 0 10px 30px rgba(120, 160, 140, 0.15);
  --radius: 20px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 登录页 ---------- */
.login-body { display: flex; align-items: center; justify-content: center; }
.sky-deco { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.cloud {
  position: absolute; background: rgba(255,255,255,0.7); border-radius: 50px;
  filter: blur(2px); animation: drift 26s linear infinite;
}
.cloud.c1 { width: 160px; height: 46px; top: 12%; left: -180px; }
.cloud.c2 { width: 110px; height: 34px; top: 30%; left: -140px; animation-duration: 34s; }
.cloud.c3 { width: 200px; height: 56px; top: 62%; left: -220px; animation-duration: 40s; }
@keyframes drift { to { transform: translateX(120vw); } }

.login-card {
  position: relative; z-index: 1;
  width: min(380px, 90vw);
  background: var(--card);
  border-radius: 28px;
  padding: 40px 34px;
  box-shadow: var(--shadow);
  text-align: center;
}
.brand-logo { font-size: 46px; }
.brand h1 { font-size: 28px; letter-spacing: 2px; margin-top: 6px; color: var(--mint-deep); }
.brand-sub { color: var(--ink-soft); margin-top: 6px; font-size: 14px; }

.login-form { margin-top: 26px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--ink-soft); }
.field input {
  font-family: var(--font); font-size: 15px; color: var(--ink);
  padding: 12px 14px; border: 1.5px solid #e3ece7; border-radius: 14px;
  background: #fbfdfc; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--mint); box-shadow: 0 0 0 4px rgba(127,200,169,0.15); }

.btn-primary {
  width: 100%; margin-top: 6px; padding: 13px; border: none; cursor: pointer;
  font-family: var(--font); font-size: 15px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-deep) 100%);
  border-radius: 14px; transition: transform .12s, box-shadow .2s; box-shadow: 0 8px 18px rgba(91,179,148,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 22px rgba(91,179,148,0.38); }
.btn-primary:active { transform: translateY(1px); }

.msg { min-height: 18px; margin-top: 12px; font-size: 13px; color: #e08a8a; text-align: center; }
.hint { margin-top: 18px; font-size: 12px; color: var(--ink-soft); line-height: 1.6; }

/* ---------- 应用页 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: rgba(255,255,255,0.75);
  backdrop-filter: blur(8px); box-shadow: 0 2px 12px rgba(120,160,140,0.08);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.site-name { font-size: 19px; font-weight: 700; color: var(--mint-deep); letter-spacing: 1px; }
.greet { color: var(--ink-soft); font-size: 14px; margin-right: 8px; }

.btn-ghost {
  border: 1.5px solid #e0eae5; background: #fff; color: var(--ink-soft);
  padding: 8px 16px; border-radius: 12px; cursor: pointer; font-family: var(--font); font-size: 13px;
  transition: all .2s;
}
.btn-ghost:hover { border-color: var(--mint); color: var(--mint-deep); }
.btn-ghost.danger { color: #d98a8a; border-color: #f0dada; }
.btn-ghost.danger:hover { background: #fdf0f0; border-color: #e7b6b6; }

.layout { display: grid; grid-template-columns: 320px 1fr; gap: 22px; padding: 24px; max-width: 1180px; margin: 0 auto; align-items: start; }

/* 侧边栏 */
.sidebar {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); position: sticky; top: 84px; max-height: calc(100vh - 108px); display: flex; flex-direction: column;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-head h2 { font-size: 16px; color: var(--ink); }
.btn-soft {
  border: none; background: #eaf6ef; color: var(--mint-deep); cursor: pointer;
  font-family: var(--font); font-size: 12px; padding: 7px 11px; border-radius: 11px; transition: background .2s;
}
.btn-soft:hover { background: #dcefe4; }

.diary-list { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.diary-item {
  border: 1.5px solid #eef4f0; border-radius: 14px; padding: 12px 13px; cursor: pointer;
  transition: all .18s; background: #fbfdfc;
}
.diary-item:hover { border-color: var(--mint); transform: translateX(2px); }
.diary-item.active { border-color: var(--mint); background: #f0faf5; box-shadow: 0 4px 12px rgba(127,200,169,0.18); }
.diary-item .di-top { display: flex; align-items: center; justify-content: space-between; }
.diary-item .di-date { font-size: 12px; color: var(--ink-soft); }
.diary-item .di-mood { font-size: 16px; }
.diary-item .di-title { margin-top: 5px; font-size: 14px; color: var(--ink); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diary-item .di-preview { margin-top: 3px; font-size: 12px; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diary-item .di-foot { margin-top: 6px; }
.diary-item .di-author { font-size: 12px; color: var(--ink-soft); }
.diary-item .di-author.me { color: var(--mint-deep); font-weight: 600; }

/* 只读（他人日记） */
.title-input:disabled, .content-input:disabled, .date-field input:disabled {
  background: #f5f7f6; color: var(--ink); cursor: default; opacity: 1;
}
.mood-opt:disabled { opacity: .55; cursor: default; transform: none; }
.list-empty { margin-top: 18px; text-align: center; font-size: 13px; color: var(--ink-soft); line-height: 1.7; }

/* 编辑器 */
.editor-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.editor-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.date-field { margin-bottom: 0; }
.date-field input { width: 160px; }
.mood-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.mood-picker { display: flex; gap: 6px; }
.mood-opt {
  font-size: 20px; width: 38px; height: 38px; border-radius: 50%; border: 2px solid #eef4f0;
  background: #fbfdfc; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .18s;
}
.mood-opt:hover { transform: scale(1.08); }
.mood-opt.active { border-color: var(--mint); background: #f0faf5; transform: scale(1.08); }

.title-input {
  width: 100%; font-family: var(--font); font-size: 19px; font-weight: 600; color: var(--ink);
  border: none; border-bottom: 2px solid #eef4f0; padding: 10px 2px; margin-bottom: 14px; outline: none; background: transparent;
  transition: border-color .2s;
}
.title-input:focus { border-color: var(--mint); }
.title-input::placeholder { color: #c4d2cb; font-weight: 500; }

.content-input {
  width: 100%; min-height: 320px; resize: vertical; font-family: var(--font); font-size: 15px; line-height: 1.9;
  color: var(--ink); border: 1.5px solid #eef4f0; border-radius: 16px; padding: 16px 18px; outline: none;
  background: #fbfdfc; transition: border-color .2s, box-shadow .2s;
}
.content-input:focus { border-color: var(--mint); box-shadow: 0 0 0 4px rgba(127,200,169,0.12); }

.editor-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.editor-actions .spacer { flex: 1; }
.save-msg { font-size: 13px; color: var(--mint-deep); }

/* ---------- 互动玩具 ---------- */
.toy-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.pet {
  position: fixed; width: 84px; height: 84px; pointer-events: auto; cursor: grab;
  user-select: none; touch-action: none; filter: drop-shadow(0 6px 8px rgba(120,160,140,0.25));
  transition: transform .15s ease;
}
.pet:active { cursor: grabbing; }
.pet svg { width: 100%; height: 100%; display: block; }
.pet.bounce { animation: petBounce .55s ease; }
@keyframes petBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.25) rotate(-6deg); }
  55% { transform: scale(.92) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

.bubble {
  position: fixed; pointer-events: none; z-index: 60; max-width: 180px;
  background: #fff; color: var(--ink); font-size: 13px; padding: 8px 12px; border-radius: 14px;
  box-shadow: var(--shadow); transform: translate(-50%, -100%);
  animation: bubbleFloat 1.8s ease forwards;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: #fff; }
@keyframes bubbleFloat {
  0% { opacity: 0; transform: translate(-50%, -80%); }
  15% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -150%); }
}

.heart {
  position: fixed; pointer-events: none; z-index: 60; font-size: 18px;
  animation: heartUp 1.2s ease forwards;
}
@keyframes heartUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(.6); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1.1); }
}

.add-toy {
  position: fixed; right: 22px; bottom: 22px; z-index: 55;
  border: none; cursor: pointer; font-family: var(--font); font-size: 14px; color: var(--ink);
  background: #fff; padding: 11px 16px; border-radius: 30px; box-shadow: var(--shadow); transition: transform .15s;
}
.add-toy:hover { transform: translateY(-2px); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: 280px; }
}
