/* ==========================================================
   Apple家的小饭桌
   视觉方向：纸上相册（见 doc/design-preview.html 方向一）
   单一视觉世界，不做深色模式；页面自己画满背景色。
   ========================================================== */

/* ---- 手写体：随项目本地保存，不走任何在线字体服务 ---- */
@font-face {
  font-family: 'Ma Shan Zheng';
  src: url('fonts/MaShanZheng-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  /* 这一页只有一个视觉世界（纸），没有深色版。
     告诉浏览器它是浅色的，否则系统开深色模式时，浏览器会把输入框、
     日期选择器的日历图标、滚动条自己涂成深色，跟纸张底色打架。 */
  color-scheme: light;

  /* 纸 */
  --paper: #efe7d6;
  --card: #fbf7ee;
  --card-shadow: rgba(58, 52, 43, 0.14);
  --photo-shadow: rgba(58, 52, 43, 0.18);

  /* 墨 */
  --ink: #3a342b;
  --ink-soft: #6e6450;
  --ink-faint: #8a7f6b;
  --hand-ink: #4a4335;

  /* 点缀 */
  --stamp-red: #b5443a;
  --tape: rgba(226, 200, 120, 0.75);
  --rule: #d8cdb4;
  --sunken: #f1ebdd;

  /* 字体 */
  --sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
  --serif: 'Songti SC', 'STSong', 'SimSun', serif;
  --hand: 'Ma Shan Zheng', 'Kaiti SC', 'STKaiti', 'KaiTi', cursive;

  --topbar-h: 78px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(8deg, rgba(58, 52, 43, 0.018) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(98deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 7px);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--stamp-red);
  outline-offset: 2px;
}

/* ==========================================================
   顶栏
   ========================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  margin-left: -8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.brand:hover {
  background: rgba(58, 52, 43, 0.06);
}

.compose-btn {
  padding: 7px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.compose-btn:hover {
  background: var(--ink);
  color: var(--card);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.identity-btn {
  min-height: 40px;
  padding: 7px 13px;
  border: 0;
  border-radius: 99px;
  background: rgba(58, 52, 43, 0.07);
  color: var(--ink);
  font: 600 13px var(--sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.identity-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--rule), 0 2px 4px var(--photo-shadow);
}

/* ==========================================================
   家庭入口：像一张放在餐桌上的家庭门牌
   ========================================================== */

.auth-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.login-card {
  position: relative;
  width: min(100%, 470px);
  padding: 42px 38px 38px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 12px 40px var(--card-shadow);
  text-align: center;
}

.login-mark {
  position: absolute;
  top: -24px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--paper);
  font-size: 24px;
  transform: translateX(-50%) rotate(-4deg);
}

.login-kicker {
  margin: 0;
  color: var(--stamp-red);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.login-title {
  margin: 2px 0 6px;
  font-family: var(--serif);
  font-size: 34px;
}

.login-intro {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 14px;
}

.login-members,
.identity-members {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.login-member,
.identity-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 10px 3px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: 12px var(--sans);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.login-member:hover,
.identity-option:hover {
  background: rgba(58, 52, 43, 0.04);
  color: var(--ink);
}

.login-member.on,
.identity-option.on {
  border-color: var(--stamp-red);
  background: rgba(181, 68, 58, 0.06);
  color: var(--ink);
}

.login-member.on .login-avatar,
.identity-option.on .login-avatar {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--stamp-red), 0 3px 8px var(--photo-shadow);
}

.login-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  object-fit: cover;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--rule), 0 3px 8px var(--photo-shadow);
}

.password-field {
  position: relative;
  margin-top: 22px;
}

.login-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 68px 10px 14px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: 16px var(--sans);
}

.password-toggle {
  position: absolute;
  top: 4px;
  right: 5px;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 13px var(--sans);
  cursor: pointer;
}

.login-error {
  min-height: 28px;
  padding-top: 7px;
  color: var(--stamp-red);
  font-size: 13px;
  text-align: left;
}

.login-submit {
  width: 100%;
  min-height: 46px;
}

/* ==========================================================
   布局
   ========================================================== */

.layout {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 96px;
}

.timeline {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* ==========================================================
   月份导航
   ========================================================== */

.months {
  position: sticky;
  top: calc(var(--topbar-h) + 12px);
  flex-shrink: 0;
  width: 118px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.months-label {
  padding: 0 10px 6px;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.month {
  padding: 5px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.month:hover {
  background: rgba(58, 52, 43, 0.06);
  color: var(--ink);
}

.month.on {
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--stamp-red);
}

/* ==========================================================
   一条记录
   ========================================================== */

.meal {
  position: relative;
  padding: 26px 24px 22px;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 2px 10px var(--card-shadow);
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

/* 日期章 */
.stamp {
  position: absolute;
  top: -11px;
  right: 22px;
  padding: 3px 12px;
  border: 2px solid var(--stamp-red);
  border-radius: 6px;
  background: var(--card);
  color: var(--stamp-red);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transform: rotate(3deg);
}

.meal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--ink-soft);
  font-size: 14px;
}

.meal-who b {
  color: var(--ink);
  font-size: 15px;
}

.avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  object-fit: cover;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--rule), 0 2px 5px var(--photo-shadow);
}

.meal-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.text-btn {
  padding: 3px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}

.text-btn:hover {
  background: rgba(58, 52, 43, 0.07);
  color: var(--ink);
}

.text-btn-danger:hover {
  background: rgba(181, 68, 58, 0.1);
  color: var(--stamp-red);
}

/* ---- 照片 ---- */

.photos {
  display: flex;
  flex-wrap: wrap;
  /* 顶部对齐：胶带贴在照片上沿，横竖照片高度不同时，上沿齐了才像贴上去的 */
  align-items: flex-start;
  gap: 16px 14px;
  margin-bottom: 4px;
}

.polaroid {
  position: relative;
  margin: 0;
  /* 照片加载前先占住一块地方，减少排版跳动 */
  min-width: 120px;
  min-height: 120px;
  padding: 8px 8px 22px;
  background: #fff;
  box-shadow: 0 3px 8px var(--photo-shadow);
  transform: rotate(var(--tilt, 0deg));
}

/* 长边统一 220px，短边按照片原始比例走：
   横照片 220×165，竖照片 165×220，方照片 220×220。
   不裁切 —— 竖着拍的就竖着显示。 */
.photo-open {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.photo-open:focus-visible {
  outline-offset: 4px;
}

.photo-open img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  width: auto;
  height: auto;
  background: var(--sunken);
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(56px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  background: rgba(28, 25, 21, 0.92);
  overscroll-behavior: contain;
}

.photo-lightbox-image {
  max-width: min(94vw, 1200px);
  max-height: calc(100svh - 92px);
  padding: 8px;
  background: var(--card);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.42);
  object-fit: contain;
  touch-action: pinch-zoom;
}

.photo-lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  padding: 0 0 3px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(28, 25, 21, 0.7);
  color: #fff;
  font: 30px/1 var(--sans);
  cursor: pointer;
}

.photo-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.tape {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 64px;
  height: 16px;
  background: var(--tape);
  transform: translateX(-50%) rotate(-1.5deg);
}

.photo-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 165px;
  border: 1px dashed var(--rule);
  background: var(--sunken);
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
}

/* ---- 感想与菜名 ---- */

.note {
  margin: 16px 0 2px;
  color: var(--hand-ink);
  font-family: var(--hand);
  font-size: 22px;
  line-height: 1.85;
  overflow-wrap: break-word;
}

.dishes {
  margin: 0 0 2px;
  color: var(--ink-faint);
  font-size: 13px;
  overflow-wrap: break-word;
}

/* ---- 评论 ---- */

.comments {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed var(--rule);
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}

.comment-who {
  flex-shrink: 0;
}

.comment-text {
  color: var(--ink-soft);
  overflow-wrap: break-word;
  min-width: 0;
}

.comment-remove {
  flex-shrink: 0;
  padding: 0 6px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
  opacity: 0;
}

/* 鼠标移到这条评论上才出现删除按钮。
   focus-visible 那条是为了键盘也能用到 —— 否则 Tab 过去看不见焦点在哪。 */
.comment:hover .comment-remove,
.comment-remove:focus-visible {
  opacity: 1;
}

.comment-remove:hover {
  background: rgba(181, 68, 58, 0.12);
  color: var(--stamp-red);
}

/* ---- 发送中 ---- */

.comment-pending .comment-text {
  opacity: 0.5;
}

.comment-spinner {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border: 2px solid var(--rule);
  border-top-color: var(--ink-faint);
  border-radius: 50%;
  animation: comment-spin 0.7s linear infinite;
}

@keyframes comment-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- 评论输入 ---- */

.comment-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.comment-list:not(:empty) + .comment-form {
  margin-top: 12px;
}

.speaker-row {
  display: flex;
  gap: 4px;
}

.chip {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  opacity: 0.38;
  cursor: pointer;
  object-fit: cover;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--rule), 0 2px 4px var(--photo-shadow);
}

@media (prefers-reduced-motion: no-preference) {
  .login-member:active,
  .identity-option:active {
    transform: translateY(1px);
  }
}

.chip:hover {
  opacity: 0.7;
}

.chip.on {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--ink);
}

.chip-static {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 1;
}

.current-author {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 14px;
}

.comment-input {
  flex: 1;
  min-width: 140px;
  padding: 5px 14px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
}

.comment-input::placeholder {
  color: var(--ink-faint);
}

.comment-submit {
  flex-shrink: 0;
  padding: 5px 16px;
  border: 1px solid var(--ink);
  border-radius: 99px;
  background: var(--ink);
  color: var(--card);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}

.comment-submit:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ==========================================================
   编辑态
   ========================================================== */

.edit-title {
  margin-bottom: 16px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
}

.edit-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}

.edit-label {
  padding-top: 7px;
  color: var(--ink-faint);
  font-size: 13px;
}

.field {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
}

textarea.field {
  resize: vertical;
}

.pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pick-avatar {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  opacity: 0.4;
  cursor: pointer;
}

.pick-avatar.on {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--ink);
}

.pick-meal {
  padding: 5px 14px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  background: #fff;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}

.pick-meal.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--card);
}

.edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.solid-btn {
  padding: 7px 20px;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  background: var(--ink);
  color: var(--card);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.solid-btn:hover:not(:disabled) {
  background: #2b2620;
}

.solid-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.edit-hint {
  margin: 12px 0 0;
  color: var(--ink-faint);
  font-size: 12px;
}

/* ==========================================================
   空状态与异常
   ========================================================== */

.empty {
  padding: 56px 32px 60px;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 2px 10px var(--card-shadow);
  text-align: center;
}

.empty-hand {
  margin: 0 0 6px;
  color: var(--hand-ink);
  font-family: var(--hand);
  font-size: 32px;
}

.empty-text {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 14px;
}

.notice {
  padding: 30px 32px 34px;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 2px 10px var(--card-shadow);
  border-top: 3px solid var(--stamp-red);
}

.notice-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--stamp-red);
}

.notice-text {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 14px;
}

.notice-steps {
  margin: 0 0 18px;
  padding-left: 22px;
  color: var(--ink-soft);
  font-size: 14px;
}

.notice-steps li {
  margin-bottom: 6px;
}

.notice code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sunken);
  color: var(--ink);
  font-size: 13px;
}

.notice-safe {
  margin: 0;
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
  color: var(--ink-faint);
  font-size: 13px;
}

/* ==========================================================
   提示条
   ========================================================== */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 40px));
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--ink-faint);
  background: var(--card);
  box-shadow: 0 4px 14px var(--card-shadow);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

.toast-error {
  border-color: var(--stamp-red);
}

/* ==========================================================
   发布浮层
   ========================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 44px 20px;
  background: rgba(46, 41, 33, 0.46);
  overflow-y: auto;
}

.sheet {
  width: 100%;
  max-width: 560px;
  padding: 28px 30px 26px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 14px 44px rgba(30, 26, 20, 0.34);
}

.sheet-title {
  margin: 0 0 22px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
}

.identity-overlay {
  align-items: center;
}

.identity-sheet {
  width: min(100%, 480px);
  padding: 28px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 14px 44px rgba(30, 26, 20, 0.34);
}

.identity-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.thumbs:not(:empty) {
  margin-bottom: 12px;
}

.thumb {
  position: relative;
  width: 84px;
  height: 84px;
}

.thumb img {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px var(--photo-shadow);
  background: var(--sunken);
}

.thumb-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 21px;
  height: 21px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.thumb-remove:hover {
  background: var(--stamp-red);
}

.add-photo {
  padding: 6px 16px;
  border: 1px dashed var(--ink-faint);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}

.add-photo:hover:not(:disabled) {
  border-color: var(--ink);
  color: var(--ink);
}

.add-photo:disabled {
  opacity: 0.45;
  cursor: default;
}

.photo-hint {
  margin-top: 7px;
  color: var(--ink-faint);
  font-size: 12px;
}

.form-status {
  min-height: 20px;
  color: var(--ink-soft);
  font-size: 13px;
}

.form-status:not(:empty) {
  margin-top: 6px;
}

.form-error {
  margin-top: 10px;
  padding: 10px 14px;
  border-left: 3px solid var(--stamp-red);
  border-radius: 4px;
  background: rgba(181, 68, 58, 0.07);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-line;
}

/* 新发布的卡片高亮一下 */
.meal.just-added {
  animation: just-added 1.2s ease-out;
}

@keyframes just-added {
  0%,
  55% {
    box-shadow: 0 2px 10px var(--card-shadow), 0 0 0 3px var(--tape);
  }
  100% {
    box-shadow: 0 2px 10px var(--card-shadow), 0 0 0 3px transparent;
  }
}

/* ==========================================================
   窄窗口：月份导航变成顶部横向标签
   ========================================================== */

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
    gap: 18px;
    padding: 20px 16px 80px;
  }

  .months {
    position: static;
    width: 100%;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .months-label {
    display: none;
  }

  .month {
    flex-shrink: 0;
    border: 1px solid var(--rule);
  }

  .month.on {
    box-shadow: none;
    border-color: var(--stamp-red);
  }

  .timeline {
    width: 100%;
  }

  /* 窄窗口把照片一起缩小，保证卡片放得下、页面不横向滚 */
  .photo-open img {
    max-width: 160px;
    max-height: 160px;
  }

  .photo-missing {
    width: 160px;
    height: 120px;
  }

  .stamp {
    right: 14px;
  }
}

@media (max-width: 560px) {
  :root { --topbar-h: 64px; }

  .topbar {
    gap: 8px;
    padding: 10px 12px;
  }

  .brand {
    max-width: 42vw;
    overflow: hidden;
    font-size: 16px;
    white-space: nowrap;
  }

  .topbar-actions { gap: 6px; }
  .identity-btn { padding: 7px 9px; }
  .compose-btn { min-height: 42px; padding: 7px 12px; font-size: 13px; }

  .layout { padding: 14px 10px 64px; }
  .months { margin-inline: -10px; width: calc(100% + 20px); padding: 0 10px 3px; }
  .month { min-height: 40px; padding-inline: 12px; }
  .meal { padding: 24px 14px 18px; }
  .meal-head { margin-bottom: 14px; }

  .photos { gap: 13px 10px; }
  .polaroid { min-width: 0; min-height: 0; max-width: calc(50% - 5px); padding: 6px 6px 18px; }
  .photo-open img { max-width: 100%; max-height: 44vw; }
  .photo-missing { width: 38vw; height: 30vw; }

  .comment { align-items: flex-start; }
  .comment-remove { min-width: 36px; min-height: 36px; margin: -7px -7px -7px auto; opacity: 1; }
  .comment-form { flex-wrap: nowrap; }
  .comment-input { min-width: 0; min-height: 42px; font-size: 16px; }
  .comment-submit { min-height: 42px; padding-inline: 14px; }

  .overlay { align-items: flex-end; padding: 12px 0 0; }
  .sheet,
  .identity-sheet {
    max-height: calc(100svh - 12px);
    overflow-y: auto;
    padding: 24px 16px max(24px, env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
  }
  .edit-row { grid-template-columns: 52px minmax(0, 1fr); gap: 8px; }
  .field { min-height: 44px; font-size: 16px; }
  .pick-avatar { width: 42px; height: 42px; }
  .pick-meal { min-height: 42px; }
  .add-photo { min-height: 44px; }
  .thumb-remove { width: 32px; height: 32px; top: -9px; right: -9px; }

  .login-card { padding: 38px 16px 24px; }
  .login-members,
  .identity-members { gap: 3px; }
  .login-member,
  .identity-option { min-height: 70px; }
  .login-avatar { width: 38px; height: 38px; }
  .identity-actions { align-items: stretch; flex-direction: column; }
  .identity-actions .text-btn { min-height: 44px; }

  .toasts { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); max-width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  /* 上面那条把转圈也停了，静止的圆环看不出在进行中，换成文字 */
  .comment-spinner {
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
  }

  .comment-spinner::after {
    content: '发送中…';
    color: var(--ink-faint);
    font-size: 12px;
  }
}
