/* 每日图片站 —— 微信内置浏览器优先
   兼容性约束：
   - 不用 flex/grid 的 gap，用 margin / column-gap
   - 不用 aspect-ratio，用 padding-top 百分比占位
   - 不依赖 srcset，图片统一走 <img src>
   - 关键属性全部带 -webkit- 前缀兜底
*/

:root {
  --bg: #0b0b0f;
  --bg-elev: #16161d;
  --bg-elev-2: #1e1e28;
  --line: #26262f;
  --text: #e8e8ee;
  --text-dim: #8b8b99;
  --accent: #4a8cff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

img { border: 0; display: block; }
button { font-family: inherit; }

/* ───────────────────────── 顶栏 ───────────────────────── */

.topbar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 11, 15, 0.92);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}

.topbar-row {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  padding: 12px 14px 10px;
}

.brand {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 28px;
  height: 28px;
  margin-right: 10px;
  border-radius: 7px;
  /* logo 是白底线稿，用白底圆角块承载，深色页面上不突兀 */
  background: #ffffff;
  -webkit-object-fit: contain;
  object-fit: contain;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

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

.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .2px;
  line-height: 1.2;
}

.brand-date {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.count-pill {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
}

/* 顶栏右侧动作区：照片数 + 「全部日期」入口。
   不用 flex gap —— iOS 13 的 WKWebView 不支持，改用 margin。 */
.topbar-actions {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

.home-link {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  margin-left: 8px;
  font-size: 12px;
  color: var(--accent);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(74, 140, 255, .18);
}

.home-link:active { background: var(--bg-elev-2); }

.home-link .chev {
  margin-left: 4px;
  font-size: 14px;
  line-height: 1;
}

/* ───────────────────────── Tab ───────────────────────── */

.tabs {
  position: relative;
  display: -webkit-flex;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  color: var(--text-dim);
  font-size: 15px;
  padding: 9px 16px 12px;
  cursor: pointer;
  -webkit-transition: color .18s ease;
  transition: color .18s ease;
  line-height: 1.3;
}

.tab.is-active { color: var(--text); font-weight: 600; }

.tab-badge {
  display: inline-block;
  margin-left: 5px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
  vertical-align: 1px;
  font-variant-numeric: tabular-nums;
}

.tab.is-active .tab-badge {
  color: #0b0b0f;
  background: var(--tab-accent, var(--accent));
  border-color: transparent;
}

.tab-ink {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--tab-accent, var(--accent));
  border-radius: 2px 2px 0 0;
  -webkit-transition: transform .26s cubic-bezier(.4, 0, .2, 1), width .26s cubic-bezier(.4, 0, .2, 1);
  transition: transform .26s cubic-bezier(.4, 0, .2, 1), width .26s cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
}

/* ───────────────────────── 网格 ───────────────────────── */

.grids { padding: 10px 0 24px; }

.grid {
  display: none;
  -webkit-column-count: 2;
  column-count: 2;
  -webkit-column-gap: 8px;
  column-gap: 8px;
  padding: 0 6px;
}

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

.cell {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding-top: 60%; /* JS 按真实比例覆写 */
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elev);
  cursor: -webkit-zoom-in;
  cursor: zoom-in;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.cell::after {
  /* 加载中的微光 */
  content: '';
  position: absolute;
  inset: 0;
  background: -webkit-linear-gradient(100deg, transparent 20%, rgba(255,255,255,.05) 50%, transparent 80%);
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.05) 50%, transparent 80%);
  background-size: 200% 100%;
  -webkit-animation: shimmer 1.4s linear infinite;
  animation: shimmer 1.4s linear infinite;
  opacity: 1;
  pointer-events: none;
  -webkit-transition: opacity .35s ease;
  transition: opacity .35s ease;
}

.cell.is-loaded::after { opacity: 0; }

.cell img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  -webkit-transition: opacity .32s ease;
  transition: opacity .32s ease;
}

.cell.is-loaded img { opacity: 1; }

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

/* ───────────────────────── 加载态 ───────────────────────── */

.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.loading[hidden] { display: none; }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-bottom: 10px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  -webkit-animation: spin .7s linear infinite;
  animation: spin .7s linear infinite;
}

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

/* ───────────────────────── 大图查看器 ───────────────────────── */

.viewer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: #000;
  -webkit-display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-touch-callout: none;
}

.viewer[hidden] { display: none; }

.viewer-bar {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  padding: calc(var(--safe-top) + 8px) 14px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,0));
}

.viewer-count {
  -webkit-flex: 1;
  flex: 1;
  font-size: 13px;
  color: rgba(255,255,255,.82);
  font-variant-numeric: tabular-nums;
}

.viewer-close {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,.12);
  border: 0;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 30px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

.viewer-stage {
  -webkit-flex: 1;
  flex: 1;
  position: relative;
  overflow: hidden;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-hint {
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,.42);
  padding: 12px 0 calc(var(--safe-bottom) + 16px);
  background: linear-gradient(0deg, rgba(0,0,0,.72), rgba(0,0,0,0));
  -webkit-transition: opacity .3s ease;
  transition: opacity .3s ease;
}

.viewer-hint.is-hidden { opacity: 0; }

/* ───────────────────────── 口令提示 ───────────────────────── */

.gate-notice {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 13px 16px calc(13px + var(--safe-bottom));
  background: rgba(74, 140, 255, .13);
  border-top: 1px solid rgba(74, 140, 255, .32);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
}

.gate-notice[hidden] { display: none; }

.gate-notice strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.gate-notice p {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* ───────────────────────── 文字标题（RSS 资讯 tab） ───────────────────────── */

/* 资讯是单列文字列表，不是多列图片网格。
   用 .grid.grid-headlines 提高优先级 —— 下面 @media 里的 .grid 多列规则会覆盖单列声明。 */
.grid.grid-headlines {
  -webkit-column-count: 1;
  column-count: 1;
  padding: 0 14px;
}

/* 标签 chips：横向滚动 */
.chips {
  display: -webkit-flex;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 10px 0 12px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 7px 13px;
  border-radius: 999px;
  margin-right: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.chip.is-active {
  color: #0b0b0f;
  background: var(--tab-accent, #3ddc97);
  border-color: transparent;
  font-weight: 600;
}

.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-item { margin: 0 0 10px; }
.news-item.is-hidden { display: none; }

.news-link {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
}
.news-link:active { background: var(--bg-elev-2); }

.news-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  font-weight: 500;
}

.news-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

.news-meta {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.news-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.5;
  background: var(--tab-accent, #3ddc97);
  color: #0b0b0f;
  margin-right: 6px;
  font-weight: 600;
}

/* ───────────────────────── 底部安全区 ───────────────────────── */

.grids { padding-bottom: calc(24px + var(--safe-bottom)); }

/* 宽屏（平板/桌面）给三列 */
@media (min-width: 700px) {
  .grid { -webkit-column-count: 3; column-count: 3; }
}
@media (min-width: 1000px) {
  .grid { -webkit-column-count: 4; column-count: 4; }
}
