/* 滚滚成长日记 — 移动端优先样式 */
:root {
  --cream: #fffcf6;
  --paper: #ffffff;
  --ink: #3d3428;
  --ink-soft: #8a7c69;
  --ink-faint: #b5a894;
  --coral: #ef8a5f;
  --coral-deep: #dd6f42;
  --coral-soft: #fdece1;
  --mint: #7fb69b;
  --mint-soft: #e6f2ec;
  --sun: #f5c26b;
  --line: #f0e8da;
  --danger: #d9534f;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 20px rgba(120, 96, 66, 0.08);
  --shadow-lg: 0 12px 36px rgba(120, 96, 66, 0.16);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* 只有一个「时光轴」视图，底部导航已移除，高度归零让内容铺满 */
  --tabbar-h: 0px;
}

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

/* hidden 属性必须真正生效：
   作者样式里写了 display:flex/grid 的元素（如 .date-filter-bar、.viewer-cover）
   会盖掉浏览器默认的 [hidden]{display:none}，导致「设了 hidden 却还显示」。
   这里统一兜底，保证 el.hidden = true 一定能隐藏。 */
[hidden] {
  display: none !important;
}

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

body {
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC',
    'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  overscroll-behavior-y: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

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

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
}

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 14px;
  background: rgba(255, 252, 246, 0.92);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  font-size: 20px;
  border-radius: 14px;
  background: var(--mint-soft);
  overflow: hidden;
}

.brand-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-size: 18px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.4px;
}

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

/* 头部音乐 / 管理员按钮共用尺寸与对齐，保持视觉一致 */
.header-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.header-btn:active {
  transform: scale(0.92);
}

/* 管理员登录按钮：尺寸放大为原来的两倍（40px → 80px），与音乐按钮区分开 */
#adminBtn {
  width: 80px;
  height: 80px;
  flex: 0 0 80px;
  font-size: 32px;
  line-height: 1;
}

/* 音乐按钮：圆圈缩到 34px，只比内部 26px 音符稍大一圈（其他头部按钮仍为 40px） */
.music-btn {
  background: var(--coral-soft);
  color: var(--coral-deep);
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}

.music-btn .music-icon {
  font-size: 26px;
  line-height: 1;
}

.music-btn:active {
  transform: scale(0.92);
}

.music-btn.is-playing {
  background: var(--coral);
  color: #fff;
  animation: spin 6s linear infinite;
}

/* 暂停态：颜色变淡（浅珊瑚底 + 珊瑚深字），不叠加 ⏸ 图标 */
.music-btn.is-paused {
  background: var(--coral-soft);
  color: var(--coral-deep);
  opacity: 1;
}

.admin-btn {
  background: var(--paper);
  color: var(--ink-soft);
  box-shadow: var(--shadow);
  font-size: 17px;
}

.admin-btn.is-active {
  background: var(--coral);
  color: #fff;
}

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

/* ---------- 主体 ---------- */
.app-main {
  padding: 0 16px;
  max-width: 720px;
  margin: 0 auto;
}

.view {
  display: none;
  padding-top: 16px;
  animation: fade 0.25s ease;
}

.view.is-active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.view-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.view-head h2 {
  font-size: 17px;
}

.view-count {
  font-size: 12.5px;
  color: var(--ink-faint);
}

/* 时光轴标题右侧的日历入口 */
.view-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 无圆形底色：只呈现图标本身，保留 28px 点击热区与按压反馈 */
.calendar-btn {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--coral-deep);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.calendar-btn:active {
  transform: scale(0.92);
  opacity: 0.6;
}

.calendar-btn-icon {
  font-size: 15px;
  line-height: 1;
}

/* 已按某日期筛选时显示的提示条 */
.date-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--coral-soft);
  color: var(--coral-deep);
  align-self: flex-start;
  max-width: 100%;
}

.date-filter-text {
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.date-filter-clear {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--coral-deep);
  font-size: 13px;
  line-height: 1;
}

/* ---------- 照片墙（移动端一排一个，避免横向挤压看不清细节） ---------- */
.photo-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.photo-card {
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.photo-card:active {
  transform: scale(0.985);
}

/* 卡片媒体区：固定横版比例，缩小图片高度，把空间留给下方文字/互动 */
.photo-carousel {
  position: relative;
  z-index: 0;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f3ede2;
  overflow: hidden;
}

.photo-carousel.is-empty {
  display: grid;
  place-items: center;
}

.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.28s ease;
}

.carousel-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
}

.carousel-slide img,
.carousel-slide video.ph-media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f3ede2;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  z-index: 2;
}

.carousel-arrow.prev {
  left: 8px;
}

.carousel-arrow.next {
  right: 8px;
}

.carousel-arrow:active {
  transform: translateY(-50%) scale(0.92);
}

/* 任意 sheet（查看器/管理员/编辑/日历）打开时：主页上视频卡片的原生控件会渲染在浏览器
   UI 最高层、盖在 sheet 底部。:has() 直接把这些视频隐藏，不依赖 JS 同步状态。 */
body:has(.sheet:not([hidden])) .photo-carousel video,
body:has(.sheet:not([hidden])) .photo-carousel .media-zoom-btn {
  display: none !important;
}

/* 视频卡片：点视频本身是播放/暂停，另给一个「放大」入口进大图查看器 */
.media-zoom-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  box-shadow: var(--shadow);
}

.media-zoom-btn:active {
  transform: scale(0.92);
}

.carousel-index {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(61, 52, 40, 0.55);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.img-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: var(--ink-faint);
}

.photo-meta {
  padding: 10px 12px 12px;
  /* 与媒体区分层：meta 始终在视频之上，保证下方文字与操作按钮不被播放器遮挡 */
  position: relative;
  z-index: 1;
}

.photo-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-date {
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* 文字记录：不再固定截断两行。
   短文本自然撑开；超过约 4 行时容器内部滚动（不撑爆卡片、不影响其他卡片）；
   出现溢出时才显示「展开全文」，点一下完整展开。 */
.photo-note {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.8em;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.photo-note.is-expanded {
  max-height: none;
  overflow: visible;
}

.note-toggle {
  margin-top: 4px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--coral-deep);
}

.note-toggle:active {
  opacity: 0.6;
}

.photo-like {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--coral-soft);
  color: var(--coral-deep);
  font-size: 12px;
}

.photo-like.is-liked {
  background: var(--coral);
  color: #fff;
}

.like-pop {
  animation: pop 0.32s ease;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.28);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- 留言 ---------- */
.composer {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.composer-author {
  width: 100%;
  border: 1px solid var(--line);
  background: #fdfaf4;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  margin-bottom: 6px;
  outline: none;
}

.composer-author:focus {
  border-color: var(--coral);
  background: #fff;
}

.composer-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfaf4;
  padding: 6px;
}

.composer-box:focus-within {
  border-color: var(--coral);
  background: #fff;
}

.composer-text {
  display: block;
  box-sizing: border-box;
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  padding: 2px 4px;
  min-height: 40px;
  max-height: 140px;
  line-height: 1.5;
  transition: height 0.12s ease;
}

/* 留言输入框随内容变多（字数/换行）切换「展开态」：动态增加上下内边距与操作行间距，让布局随内容呼吸 */
.composer.is-grown {
  padding: 12px;
}

.composer.is-grown .composer-box {
  padding: 8px;
}

.composer.is-grown .composer-actions {
  margin-top: 8px;
}

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

.counter {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-right: auto;
}

.voice-btn,
.send-btn,
.ghost-btn,
.primary-btn,
.danger-btn,
.load-more {
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13.5px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.voice-btn {
  background: var(--mint-soft);
  color: #4e8a6f;
}

.voice-btn.is-recording {
  background: var(--danger);
  color: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

.send-btn,
.primary-btn {
  background: var(--coral);
  color: #fff;
  font-weight: 600;
}

.voice-btn:active,
.send-btn:active,
.primary-btn:active,
.ghost-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled,
.primary-btn:disabled {
  opacity: 0.5;
}

.ghost-btn {
  background: #f4efe6;
  color: var(--ink-soft);
}

.danger-btn {
  background: #fdeceb;
  color: var(--danger);
}

.voice-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 留言区整体更紧凑：缩小内边距、缩小头像、收紧行距与元素间距 */
.message-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 9px 12px;
  box-shadow: var(--shadow);
  animation: rise 0.3s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.message-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--sun), var(--coral));
}

.message-who {
  font-size: 13.5px;
  font-weight: 600;
}

.message-time {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-left: auto;
}

.tag-voice {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--mint-soft);
  color: #4e8a6f;
}

.message-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--coral-soft);
  color: var(--coral-deep);
  font-size: 12.5px;
}

.like-btn.is-liked {
  background: var(--coral);
  color: #fff;
}

.comment-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--coral);
  background: var(--paper);
  color: var(--coral-deep);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.comment-toggle:active {
  transform: scale(0.96);
}

.comment-toggle.is-open {
  background: var(--coral);
  color: #fff;
}

.comment-toggle-icon {
  font-size: 13px;
  line-height: 1;
}

.msg-delete {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-faint);
  padding: 4px 8px;
}

.load-more {
  display: block;
  width: 100%;
  margin: 14px 0 6px;
  background: #f4efe6;
  color: var(--ink-soft);
}

/* ---------- 数据 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--coral-deep);
  line-height: 1.2;
}

.stat-label {
  font-size: 12.5px;
  color: var(--ink-soft);
}

.panel {
  margin-top: 16px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--ink-soft);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 110px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  height: 100%;
  justify-content: flex-end;
}

.bar-wrap {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
}

.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--sun), var(--coral));
  border-radius: 6px 6px 3px 3px;
  min-height: 3px;
  transition: height 0.4s ease;
}

.bar-label {
  font-size: 10.5px;
  color: var(--ink-faint);
}

.bar-value {
  font-size: 10.5px;
  color: var(--ink-soft);
}

.ratio-bar {
  display: flex;
  height: 26px;
  border-radius: 999px;
  overflow: hidden;
  background: #f0e9dd;
}

.ratio-seg {
  display: grid;
  place-items: center;
  font-size: 11.5px;
  color: #fff;
  transition: width 0.4s ease;
  overflow: hidden;
  white-space: nowrap;
}

.ratio-text {
  background: var(--coral);
}

.ratio-voice {
  background: var(--mint);
}

.ratio-legend {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.ratio-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

.dot-text {
  background: var(--coral);
}

.dot-voice {
  background: var(--mint);
}

.sync-note {
  margin: 16px 0 4px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ---------- 空态 / 骨架 ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-faint);
}

.empty-emoji {
  font-size: 38px;
  margin-bottom: 8px;
}

.empty-title {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--ink-soft);
}

.empty-desc {
  margin: 0;
  font-size: 12.5px;
}

.skeleton-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.skeleton-card {
  height: 170px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #f4ede2 30%, #fbf7f0 50%, #f4ede2 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite;
}

.skeleton-row {
  height: 72px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #f4ede2 30%, #fbf7f0 50%, #f4ede2 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite;
  margin-bottom: 10px;
}

@keyframes shimmer {
  from {
    background-position: 180% 0;
  }
  to {
    background-position: -40% 0;
  }
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 252, 246, 0.94);
  backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-faint);
  font-size: 11px;
}

.tab.is-active {
  color: var(--coral-deep);
}

.tab-icon {
  font-size: 18px;
  line-height: 1;
}

/* ---------- 弹层 ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] {
  display: none;
}

/* 查看器：媒体在视口中垂直居中（而非底部抽屉），水平已由 justify-content:center 居中；
   访客态下 .viewer-body 隐藏，卡片即媒体本身，媒体正好位于屏幕正中；管理员态整卡居中。 */
.sheet.viewer-center {
  align-items: center;
}

.sheet.viewer-center .viewer {
  border-radius: 22px;
  max-height: 92vh;
}

/* ---------- 日历弹层：按日期查看当天记录 ---------- */
.calendar-pop {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--cream);
  border-radius: 20px;
  padding: 16px 14px 14px;
  box-shadow: var(--shadow-strong, var(--shadow));
  animation: slideUp 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.cal-nav {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 19px;
  line-height: 1;
}

.cal-nav:active {
  transform: scale(0.92);
}

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.cal-week span {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-faint);
  padding: 2px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--ink);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

/* 有记录的日期：浅珊瑚底 + 下方小圆点 */
.cal-day.has-rec {
  background: var(--coral-soft);
  color: var(--coral-deep);
  font-weight: 600;
}

.cal-day.has-rec::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--coral);
}

.cal-day.is-today {
  box-shadow: inset 0 0 0 1px var(--coral);
}

.cal-day.is-selected {
  background: var(--coral);
  color: #fff;
  font-weight: 700;
}

.cal-day.is-selected::after {
  background: #fff;
}

/* 上一月 / 下一月的补位日期 */
.cal-day.is-other {
  color: var(--ink-faint);
  opacity: 0.45;
}

.cal-tip {
  margin: 10px 0 8px;
  font-size: 11.5px;
  color: var(--ink-faint);
  text-align: center;
}

.cal-foot {
  display: flex;
  gap: 8px;
}

.cal-foot-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 12px;
  border: 1px solid var(--coral);
  background: var(--paper);
  color: var(--coral-deep);
  font-size: 13.5px;
  font-weight: 500;
}

.cal-foot-btn:active {
  transform: scale(0.97);
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(52, 42, 30, 0.42);
  animation: fade 0.2s ease;
}

.viewer,
.admin-panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--cream);
  border-radius: 22px 22px 0 0;
  animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: calc(20px + var(--safe-bottom));
}

.admin-panel {
  padding: 18px 18px calc(22px + var(--safe-bottom));
}

.admin-panel.small {
  padding: 18px;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

.viewer {
  padding: 0 0 calc(16px + var(--safe-bottom));
  background: var(--paper);
}

/* 媒体舞台：承载媒体 + 左右切换 + 计数指示，均为覆盖层，不占布局高度 */
.viewer-stage {
  position: relative;
  z-index: 0;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  box-shadow: var(--shadow);
}

.viewer-nav.prev {
  left: 10px;
}

.viewer-nav.next {
  right: 10px;
}

.viewer-nav:active {
  transform: translateY(-50%) scale(0.92);
}

.viewer-counter {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(61, 52, 40, 0.55);
  color: #fff;
  font-size: 12.5px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.viewer-media {
  background: #f3ede2;
  display: grid;
  place-items: center;
  overflow: auto;
}

.viewer-media img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.2s ease;
}

/* 查看器打开即「放大居中、适配屏幕」：图片在保持比例下尽量填满可视区，居中且不裁切、不横向溢出；
   再次点击图片还原为按列宽显示（fit-width）。 */
.viewer-media img.is-zoomed {
  max-width: 100%;
  max-height: 84vh;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto;
  cursor: zoom-out;
}

.viewer-media video {
  width: 100%;
  max-height: 84vh;
  object-fit: contain;
  display: block;
  background: #000;
}

.viewer-close,
.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.viewer-body {
  padding: 16px 18px 0;
  /* 与媒体分层：编辑 / 删除等操作永远压在视频之上，不会被播放器覆盖 */
  position: relative;
  z-index: 1;
}

.viewer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.viewer-head h3 {
  font-size: 17px;
}

.viewer-date {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* 查看器里的文字记录：长文完整显示，由 .viewer（max-height + overflow-y:auto）整体滚动，
   不截断、不溢出卡片 */
.viewer-note {
  margin: 8px 0 0;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.viewer-note:empty {
  margin: 0;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.viewer-admin {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* 访客态查看器：只保留媒体 + 关闭，隐藏标题/点赞/留言/编辑/删除，界面更干净居中 */
.viewer.is-visitor .viewer-body {
  display: none;
}

.viewer-cover {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cover-tip {
  font-size: 12px;
  color: var(--ink-faint);
}


/* ---------- 管理面板 ---------- */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h3 {
  font-size: 16.5px;
}

.admin-login {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-login input,
.text-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  resize: vertical;
}

.admin-login input:focus,
.text-input:focus {
  border-color: var(--coral);
}

.admin-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-section h4 {
  font-size: 14px;
  color: var(--ink);
}

.admin-current {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  word-break: break-all;
}

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

.admin-tip {
  margin: 0;
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
}

.admin-tip.is-ok {
  color: #4e8a6f;
}

.file-picker {
  display: block;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  background: var(--paper);
  cursor: pointer;
}

.file-picker input {
  display: none;
}

/* 已选文件清单：清晰可见每个文件名，支持逐条移除 / 清空重选 */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: 13px;
}

.file-chip-icon {
  flex: 0 0 auto;
  font-size: 15px;
}

.file-chip-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.file-chip-meta {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.file-chip-remove {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f4efe6;
  color: var(--ink-soft);
  font-size: 13px;
}

.file-chip-remove:active {
  transform: scale(0.9);
}

.text-link {
  align-self: flex-start;
  margin-top: 2px;
  padding: 4px 2px;
  font-size: 13px;
  color: var(--coral-deep);
  text-decoration: underline;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.field-row input {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--paper);
  outline: none;
}

.row-btns {
  display: flex;
  gap: 10px;
}

.row-btns > * {
  flex: 1;
}

.ghost-btn.block {
  width: 100%;
  margin-top: 16px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 74px);
  transform: translateX(-50%);
  z-index: 90;
  max-width: 82vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(61, 52, 40, 0.92);
  color: #fff;
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.24s ease;
}

.toast[hidden] {
  display: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------- 大屏适配 ---------- */
@media (min-width: 720px) {
  .app-main {
    padding: 0 24px;
  }
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- 日记详情内的留言区 ---------- */
.photo-engagement {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  /* 提升层级：操作按钮始终在视频播放器之上，不会被控件条或视频图层盖住 */
  position: relative;
  z-index: 1;
}

/* 管理模式：卡片上的编辑 / 删除（视频卡片同样可见可点，不依赖视频区域点击进入查看器） */
.photo-admin {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-edit-btn,
.photo-del-btn {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.5;
}

.photo-edit-btn {
  background: #f4efe6;
  color: var(--ink-soft);
}

.photo-del-btn {
  background: #fdeceb;
  color: var(--danger);
}

.photo-edit-btn:active,
.photo-del-btn:active {
  transform: scale(0.95);
}

.photo-engagement .photo-like {
  margin-top: 0;
}

.photo-comments,
.photo-comment-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--mint-soft, #e8f3ec);
  color: #4e8a6f;
  font-size: 12px;
}

.photo-comment-btn {
  transition: background 0.18s ease, color 0.18s ease;
}

.photo-comment-btn:active {
  transform: scale(0.96);
}

.photo-comment-btn.is-open {
  background: #4e8a6f;
  color: #fff;
}

/* ---------- 卡片就地展开的留言区 ---------- */
.card-comments {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
  background: #fbf8f2;
  animation: cc-slide-in 0.22s ease;
}

@keyframes cc-slide-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-comments .cc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-comments .cc-list .message-card {
  box-shadow: none;
  border: 1px solid var(--line);
  animation: none;
  background: var(--paper);
}

.cc-empty {
  margin: 2px 0 8px;
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}

.cc-composer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.cc-author {
  flex: 0 0 100%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 13px;
  color: var(--ink);
}

.cc-input {
  flex: 1 1 160px;
  display: block;
  box-sizing: border-box;
  min-height: 34px;
  max-height: 96px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 13.5px;
  color: var(--ink);
  resize: none;
  font-family: inherit;
  transition: height 0.12s ease;
}

.cc-send {
  flex: 0 0 auto;
  padding: 0 16px;
  min-height: 34px;
  border-radius: 10px;
  background: var(--coral);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
}

.cc-send:disabled {
  opacity: 0.55;
}

.cc-author:focus,
.cc-input:focus {
  outline: none;
  border-color: var(--coral);
}

/* ---------- 管理员「全站留言总览」 ---------- */
.admin-messages {
  margin-top: 10px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 4px;
}

.admin-messages .adm-msg {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.admin-messages .adm-msg:last-child {
  border-bottom: none;
}

.admin-messages .adm-msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.admin-messages .adm-msg-who {
  font-weight: 600;
  color: var(--ink);
}

.admin-messages .adm-msg-where {
  font-size: 12px;
  color: var(--ink-faint);
}

.admin-messages .adm-msg-where.adm-msg-orphan {
  color: #b5683a;
}

.admin-messages .adm-msg-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-faint);
}

.admin-messages .adm-msg-text {
  margin: 4px 0 8px;
  color: var(--ink-soft);
  word-break: break-word;
}

.admin-messages .adm-msg-bottom {
  display: flex;
  justify-content: flex-end;
}

.admin-messages .danger-btn.small {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
}

.viewer-comments {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.comments-title {
  margin: 0 0 8px;
  font-size: 14.5px;
  font-weight: 600;
}

.comments-count {
  color: var(--ink-faint);
  font-weight: 400;
  font-size: 12.5px;
}

.viewer-comments .message-list {
  margin-bottom: 8px;
}

.viewer-comments .message-card {
  box-shadow: none;
  border: 1px solid var(--line);
  animation: none;
}

.comments-empty {
  margin: 4px 0 10px;
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}

.viewer-comments .composer {
  margin-bottom: 0;
  /* 钉在弹层底部，长留言列表滚动时输入框始终完整可见，不被上方留言遮挡 */
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--paper);
  box-shadow: 0 -8px 16px -10px rgba(60, 40, 20, 0.18);
  border: 1px solid var(--line);
}
