/* ══════════════════════════════════════════════════════════════
   diary.css —— 日记模块（Instagram 式网格、时间线、写日记、看大图）
   ══════════════════════════════════════════════════════════════ */

/* ---------- 头像环与计数 ---------- */

.dy-ring {
  --size: 40px;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  padding: 2.5px;
  background: linear-gradient(45deg, #feda75, #fa7e1e 25%, #d62976 55%, #962fbf 80%, #4f5bd5);
  display: inline-flex;
  flex: 0 0 auto;
}
.dy-ring span {
  flex: 1;
  border-radius: 50%;
  border: 2.5px solid var(--bg);
  background: var(--fill);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: calc(var(--size) * 0.38); letter-spacing: 0.02em;
}
.dy-ring.sm { --size: 34px; padding: 2px; }
.dy-ring.sm span { border-width: 2px; }
.dy-ring.lg { --size: 96px; padding: 3.5px; }
.dy-ring.lg span { border-width: 4px; }

.dy-profile {
  max-width: 935px;
  margin: 0 auto 30px;
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 0 12px;
}
.dy-counts { display: flex; gap: 40px; flex: 1; }
.dy-counts div { display: flex; flex-direction: column; gap: 2px; }
.dy-counts b {
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.dy-counts span { font-size: 13px; color: var(--text-secondary); }
.dy-profile .tile-cta { margin: 0; }

.dy-bar {
  max-width: 935px;
  margin: 0 auto 14px;
  padding: 14px 12px 0;
  border-top: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.dy-bar .sec { font-size: 12.5px; }

/* ---------- 网格 ---------- */

.dy-grid {
  max-width: 935px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.dy-cell {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 0; padding: 0; margin: 0;
  background: var(--fill);
  overflow: hidden;
  cursor: pointer;
  animation: dyIn 0.55s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
@keyframes dyIn { from { opacity: 0; transform: scale(0.97); } }
.dy-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s var(--ease-out); }
.dy-textcell {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  color: #fff; font-size: 15px; font-weight: 600; line-height: 1.5; text-align: center;
  background: linear-gradient(135deg, var(--g1), var(--g2) 55%, var(--g3));
  overflow: hidden;
}
.dy-multi {
  position: absolute; top: 9px; right: 9px;
  width: 20px; height: 20px;
  fill: none; stroke: #fff; stroke-width: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.dy-vbadge, .dy-th-dur {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px 3px 6px; border-radius: 980px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.dy-vbadge svg, .dy-th-dur svg { width: 12px; height: 12px; fill: #fff; }
.dy-th-dur { top: auto; bottom: 5px; right: 5px; font-size: 10.5px; padding: 2px 7px 2px 5px; }
.dy-hover {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: #fff; background: rgba(0, 0, 0, 0.32);
  opacity: 0; transition: opacity 0.25s var(--ease);
}
.dy-hover b { font-size: 16px; }
.dy-hover small { font-size: 12.5px; opacity: 0.9; }
@media (hover: hover) {
  .dy-cell:hover .dy-hover { opacity: 1; }
  .dy-cell:hover img { transform: scale(1.04); }
}
.dy-cell:focus-visible { outline: 3px solid var(--g2); outline-offset: -3px; }

.dy-skel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.dy-skel i {
  aspect-ratio: 3 / 4;
  background: linear-gradient(90deg, var(--fill), var(--hairline), var(--fill));
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  opacity: 0.6;
}
.dy-empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 70px 0 90px; text-align: center;
}
.dy-empty .dy-ring { margin-bottom: 10px; }
.dy-empty b { font-size: 22px; }
.dy-empty span { color: var(--text-secondary); font-size: 14px; }
.dy-sentinel { height: 1px; }
.dy-grid[hidden], .dy-feed[hidden] { display: none; }

/* ---------- 时间线 ---------- */

.dy-feed { max-width: 470px; margin: 0 auto; display: flex; flex-direction: column; }
.dy-feed .dy-empty { padding-top: 50px; }
.dy-card { padding: 0 0 26px; margin-bottom: 18px; border-bottom: 1px solid var(--hairline); }
.dy-card-head, .dy-v-head { display: flex; align-items: center; gap: 11px; padding: 10px 2px; }
.dy-card-head div, .dy-v-head div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dy-card-head b, .dy-v-head b { font-size: 14px; }
.dy-card-head small, .dy-v-head small { font-size: 12px; color: var(--text-secondary); }
.dy-open, .dy-x {
  width: 34px; height: 34px; border: 0; background: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text);
}
.dy-open svg { width: 20px; height: 20px; fill: currentColor; }
.dy-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.dy-open:hover, .dy-x:hover { background: var(--fill); }
.dy-caption { font-size: 15px; line-height: 1.6; padding: 12px 2px 0; cursor: pointer; word-break: break-word; }
.dy-caption.big {
  font-size: 19px; font-weight: 600; line-height: 1.5;
  padding: 28px 24px; border-radius: 14px; color: #fff;
  background: linear-gradient(135deg, var(--g1), var(--g2) 55%, var(--g3));
}
.dy-caption.big .dy-tag { color: #fff; -webkit-text-fill-color: #fff; text-decoration: underline; }
.dy-tag {
  font-weight: 600;
  background-image: linear-gradient(90deg, var(--g2), var(--g3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- 轮播 ---------- */

.dy-car {
  position: relative;
  aspect-ratio: var(--ar, 1);
  background: #000;
  border-radius: 6px;
  overflow: hidden;
}
.dy-track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.dy-track::-webkit-scrollbar { display: none; }
.dy-track video {
  flex: 0 0 100%; width: 100%; height: 100%;
  object-fit: contain; background: #000; scroll-snap-align: center;
}
.dy-track img {
  flex: 0 0 100%;
  width: 100%; height: 100%;
  object-fit: cover;
  scroll-snap-align: center;
  user-select: none; -webkit-user-drag: none;
}
.dy-nav {
  position: absolute; top: 50%;
  width: 30px; height: 30px; margin-top: -15px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.dy-nav[hidden] { display: none; }
.dy-nav svg { width: 16px; height: 16px; fill: none; stroke: #1d1d1f; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.dy-nav:active { transform: scale(0.9); }
.dy-nav.prev { left: 10px; }
.dy-nav.next { right: 10px; }
.dy-count {
  position: absolute; top: 10px; right: 10px;
  font-size: 12px; font-weight: 600; color: #fff;
  background: rgba(0, 0, 0, 0.55); padding: 3px 9px; border-radius: 980px;
}
.dy-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; pointer-events: none; }
/* 有视频的轮播，圆点挪到顶部，别压住播放控件 */
.dy-car:has(video) .dy-dots { bottom: auto; top: 14px; }
.dy-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.5); transition: background 0.2s var(--ease), transform 0.2s var(--ease); }
.dy-dots i.on { background: #fff; transform: scale(1.15); }
@media (hover: none) { .dy-nav { display: none; } }

/* ---------- 弹层 ---------- */

html.dy-lock { overflow: hidden; }
.dy-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transition: opacity 0.28s var(--ease);
}
.dy-modal[hidden] { display: none; }
.dy-modal.open { opacity: 1; }
.dy-sheet, .dy-view {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  transform: translateY(26px) scale(0.98);
  transition: transform 0.4s var(--ease-out);
}
.dy-modal.open .dy-sheet, .dy-modal.open .dy-view { transform: none; }

/* 写日记 */
.dy-sheet {
  width: min(580px, 100%);
  max-height: min(90vh, 900px);
  border-radius: 22px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.dy-sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--hairline);
}
.dy-sheet-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.dy-sheet-head .btn-link { justify-self: start; color: var(--text-secondary); }
.dy-sheet-head .btn-primary {
  justify-self: end; border: 0; color: #fff;
  background: linear-gradient(92deg, var(--g1), var(--g2) 55%, var(--g3));
}
.dy-sheet-head .btn-primary:disabled { opacity: 0.4; }
.dy-sheet-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }

.dy-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 200px; padding: 24px;
  border-radius: 16px;
  border: 1.5px dashed color-mix(in srgb, var(--g2) 45%, var(--hairline));
  background: color-mix(in srgb, var(--g2) 5%, var(--bg));
  cursor: pointer; text-align: center;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), min-height 0.3s var(--ease-out);
}
.dy-drop svg { width: 44px; height: 44px; fill: none; stroke: var(--g2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
.dy-drop b { font-size: 16px; }
.dy-drop span { font-size: 13px; color: var(--text-secondary); }
.dy-drop:hover, .dy-drop.over { background: color-mix(in srgb, var(--g2) 11%, var(--bg)); border-color: var(--g2); }
.dy-drop.compact { min-height: 0; flex-direction: row; padding: 12px; gap: 10px; }
.dy-drop.compact svg { width: 22px; height: 22px; margin: 0; }
.dy-drop.compact span { display: none; }
.dy-drop.compact b { font-size: 14px; }

.dy-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.dy-thumbs:empty { display: none; }
.dy-th {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--fill);
  animation: dyIn 0.35s var(--ease-out) both;
}
.dy-th img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.dy-th.bad { background: color-mix(in srgb, var(--danger) 10%, var(--bg)); }
.dy-th-err { position: absolute; inset: 0; padding: 8px; font-size: 11px; line-height: 1.4; color: var(--danger); display: flex; align-items: center; }
.dy-th-x {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 15px; line-height: 1; cursor: pointer;
}
.dy-th-cover {
  position: absolute; left: 5px; bottom: 5px;
  font-size: 10.5px; font-weight: 600; color: #fff; padding: 2px 7px; border-radius: 980px;
  background: linear-gradient(90deg, var(--g1), var(--g2));
}
.dy-spin {
  position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: 50%; border: 2.5px solid var(--hairline); border-top-color: var(--g2);
  animation: dySpin 0.8s linear infinite;
}
@keyframes dySpin { to { transform: rotate(360deg); } }

.dy-text { resize: vertical; min-height: 110px; font: inherit; font-size: 15px; line-height: 1.6; }
.dy-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dy-fields label { display: flex; flex-direction: column; gap: 5px; }
.dy-fields span { font-size: 12px; color: var(--text-secondary); }
.dy-progress { position: relative; height: 26px; border-radius: 980px; background: var(--fill); overflow: hidden; }
.dy-progress[hidden] { display: none; }
.dy-progress i {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, var(--g1), var(--g2), var(--g3));
  transition: width 0.4s var(--ease-out);
}
.dy-progress span { position: relative; display: block; text-align: center; line-height: 26px; font-size: 12px; font-weight: 600; color: #fff; mix-blend-mode: difference; }
.dy-msg { font-size: 13px; min-height: 0; }
.dy-msg:empty { display: none; }
.dy-note { font-size: 12px; color: var(--text-secondary); line-height: 1.6; margin: 0; }

/* 看日记 */
.dy-view {
  width: min(1120px, 100%);
  height: min(90vh, 820px);
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}
.dy-v-media { background: #000; min-height: 0; display: flex; }
.dy-v-media { overflow: hidden; }
.dy-v-media .dy-car { flex: 1; min-width: 0; aspect-ratio: auto; border-radius: 0; }
.dy-v-media .dy-track img { object-fit: contain; }
.dy-v-media.empty { background: none; }
.dy-textonly {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 48px; color: #fff; font-size: 26px; font-weight: 700; line-height: 1.5; text-align: center;
  background: linear-gradient(135deg, var(--g1), var(--g2) 55%, var(--g3));
  overflow-y: auto;
}
.dy-textonly .dy-tag { color: #fff; -webkit-text-fill-color: #fff; }
.dy-v-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--hairline); }
.dy-v-head { padding: 12px 14px; border-bottom: 1px solid var(--hairline); }
.dy-v-read, .dy-v-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dy-v-read[hidden], .dy-v-editor[hidden] { display: none; }
.dy-v-caption { flex: 1; overflow-y: auto; padding: 16px; font-size: 15px; line-height: 1.7; word-break: break-word; }
.dy-v-editor { padding: 14px; gap: 10px; overflow-y: auto; }
.dy-v-editor .dy-fields { grid-template-columns: 1fr; }
.dy-v-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--hairline); margin-top: auto; }
.dy-v-editor .dy-v-actions { padding: 12px 0 0; }
.dy-del { color: var(--danger); }
.dy-del.arm { background: var(--danger); border-color: var(--danger); color: #fff; }

.br-sm { display: none; }

/* ══════════════ 平板 ══════════════ */
@media (max-width: 1068px) {
  .dy-view { grid-template-columns: minmax(0, 1fr) 300px; }
  .dy-profile { gap: 24px; }
  .dy-counts { gap: 24px; min-width: 0; }
}

/* ══════════════ 手机 ══════════════ */
@media (max-width: 734px) {
  .br-sm { display: inline; }
  .dy-profile { gap: 18px; flex-wrap: wrap; padding: 0 4px; margin-bottom: 22px; }
  .dy-ring.lg { --size: 78px; }
  .dy-counts { gap: 0; justify-content: space-around; }
  .dy-counts b { font-size: 21px; }
  .dy-counts span { font-size: 12px; }
  .dy-profile .tile-cta { width: 100%; justify-content: center; }
  .dy-grid, .dy-skel { gap: 2px; }
  .dy-bar { padding: 12px 4px 0; }
  .dy-hover { display: none; }
  .dy-card { margin: 0 -16px 14px; padding-bottom: 20px; }
  .dy-card-head { padding: 8px 14px; }
  .dy-card .dy-caption { padding: 10px 14px 0; }
  .dy-card .dy-caption.big { margin: 0 14px; }
  .dy-car { border-radius: 0; }

  .dy-modal { padding: 0; align-items: flex-end; }
  .dy-sheet {
    width: 100%; max-height: calc(100% - 20px);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dy-fields { grid-template-columns: 1fr; }
  .dy-modal#dy-viewer { align-items: stretch; }
  .dy-view {
    width: 100%; height: 100%; border-radius: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    transform: translateY(40px);
  }
  .dy-v-media { order: 2; max-height: 62vh; }
  .dy-v-media .dy-car { aspect-ratio: var(--ar, 1); max-height: 62vh; }
  .dy-v-media.empty { max-height: none; }
  .dy-textonly { font-size: 21px; padding: 36px 24px; }
  .dy-v-side { display: contents; }
  .dy-v-head { order: 1; padding-top: calc(10px + env(safe-area-inset-top)); }
  .dy-v-read, .dy-v-editor { order: 3; }
  .dy-view { grid-template-rows: auto auto minmax(0, 1fr); overflow-y: auto; }
  .dy-v-caption { overflow: visible; }
  .dy-v-actions { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .dy-cell, .dy-th { animation: none; }
  .dy-modal, .dy-sheet, .dy-view { transition: none; }
}
