/* ───────── 色板：拉丝钢狗牌、柔光背景 ───────── */
:root {
  --ground: #EFECE6;      /* 暖白背景的底色 */
  --backdrop: radial-gradient(120% 100% at 50% 0%, #FAF8F4 0%, #EFECE6 52%, #E1DDD5 100%);
  --ink: #24292D;         /* 刻在钢上的石墨字，正文和线条 */
  --muted: #635E57;
  --line: rgba(36, 41, 45, 0.16);
  --ball: #C9CFD4;        /* 拉丝钢的素色，用在筛选 */
  --on-ball: #24292D;
  --ph: #DCD7CF;          /* 照片加载前的底色 */

  /* 狗牌：细密的圆形拉丝 + 强高光 + 边缘压暗，做出钢的球面反光 */
  --metal:
    repeating-conic-gradient(from 0deg at 50% 50%,
      rgba(255, 255, 255, 0.16) 0deg 0.55deg,
      rgba(255, 255, 255, 0) 0.55deg 1.35deg,
      rgba(22, 28, 33, 0.07) 1.35deg 1.9deg),
    radial-gradient(120% 120% at 30% 16%, rgba(255, 255, 255, 0.98), transparent 46%),
    radial-gradient(circle at 50% 42%, transparent 52%, rgba(20, 26, 31, 0.28) 96%),
    linear-gradient(145deg, #FFFFFF 0%, #AEB7BE 14%, #F7FAFB 31%, #8B959D 50%,
                    #E9EDF0 66%, #9BA5AD 82%, #6E7880 100%);
  --tag-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.95),
    inset 3px 0 4px rgba(255, 255, 255, 0.35),
    inset -3px -3px 6px rgba(15, 21, 25, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55),
    0 0 0 1.5px rgba(62, 70, 76, 0.22),
    0 0.9rem 1.4rem -0.6rem rgba(50, 44, 36, 0.5);

  --gutter: clamp(1rem, 4vw, 2.5rem);
  --sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  /* 圆体只给数字用（苹果设备上有，其他设备回退到系统字体） */
  --round: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #151412;
    --backdrop: radial-gradient(120% 100% at 50% 0%, #242220 0%, #171614 52%, #0F0E0D 100%);
    --ink: #E9E5DE;
    --muted: #A39D94;
    --line: rgba(233, 229, 222, 0.18);
    --ph: #242220;

    /* 夜里钢牌照样反光，只是压暗了一档 */
    --metal:
      repeating-conic-gradient(from 0deg at 50% 50%,
        rgba(255, 255, 255, 0.1) 0deg 0.55deg,
        rgba(255, 255, 255, 0) 0.55deg 1.35deg,
        rgba(0, 0, 0, 0.1) 1.35deg 1.9deg),
      radial-gradient(120% 120% at 30% 16%, rgba(255, 255, 255, 0.7), transparent 46%),
      radial-gradient(circle at 50% 42%, transparent 52%, rgba(0, 0, 0, 0.38) 96%),
      linear-gradient(145deg, #F2F5F6 0%, #9DA7AE 14%, #DCE2E5 31%, #7C868E 50%,
                      #C7CED3 66%, #8B959C 82%, #5F6971 100%);
    --tag-shadow:
      inset 0 2px 1px rgba(255, 255, 255, 0.7),
      inset 3px 0 4px rgba(255, 255, 255, 0.2),
      inset -3px -3px 6px rgba(0, 0, 0, 0.5),
      inset 0 0 0 1px rgba(255, 255, 255, 0.2),
      0 0 0 1.5px rgba(0, 0, 0, 0.4),
      0 0.9rem 1.4rem -0.6rem rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--ground);
  background-image: var(--backdrop);
  background-attachment: fixed;
  color: var(--ink);
  font: 1.0625rem/1.85 var(--sans);
  -webkit-text-size-adjust: 100%;
}

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

html:has(dialog[open]) { overflow: hidden; }

/* ───────── 页面骨架 ───────── */
.page {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.feed { padding-top: 2.5rem; }
.foot { padding: 1rem 0 3rem; color: var(--muted); }

@media (min-width: 56rem) {
  .page {
    display: grid;
    grid-template-columns: 16.5rem minmax(0, 1fr);
    grid-template-rows: 1fr auto;
    column-gap: 4.5rem;
    align-items: start;
    min-height: 100vh;
  }
  .side { grid-row: 1 / span 2; }
  .feed { grid-column: 2; padding-top: 3rem; }
  .foot { grid-column: 2; }
}

/* 屏幕够高时，狗牌一直挂在窗口顶部 */
@media (min-width: 56rem) and (min-height: 50rem) {
  .side { position: sticky; top: 0; }
}

/* ───────── 狗牌（整页唯一的重点） ───────── */
.side {
  --tag: 15rem;
  --tag-scale: 1;
}

@media (max-width: 55.99rem) {
  .side { --tag: 10.5rem; --tag-scale: 0.7; }
}

.tag-wrap {
  position: relative;
  width: var(--tag);
  padding-top: 1.5rem;
}

.tag {
  position: relative;
  width: var(--tag);
  height: var(--tag);
  padding: 0.65em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(1rem * var(--tag-scale));
  background: var(--metal);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--tag-shadow);
}

.tag-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0.18em 0.24em rgba(20, 25, 29, 0.34));
  user-select: none;
  -webkit-user-drag: none;
}

/* ───────── 简介、筛选、链接 ───────── */
.bio { margin: 1.5rem 0 0; max-width: 20em; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0 0; }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 1rem;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { background: color-mix(in srgb, var(--ball) 45%, transparent); }
.chip[aria-current="page"] {
  color: var(--on-ball);
  background: var(--ball);
  border-color: var(--ball);
  font-weight: 700;
}
.chip .count {
  margin-left: 0.45em;
  font-family: var(--round);
  font-weight: 700;
  opacity: 0.65;
}
@media (pointer: coarse) { .chip { min-height: 2.75rem; } }

.links { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.links a { color: var(--ink); text-underline-offset: 0.25em; text-decoration-thickness: 2px; }

/* ───────── 日记列表 ───────── */
.month {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 3.25rem 0 1.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}
.month::after { content: ""; flex: 1; height: 1.5px; background: var(--line); }
.month:first-child { margin-top: 0; }

.entry {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  column-gap: 1.5rem;
  padding-bottom: 3.5rem;
}
.entry:focus { outline: none; }

/* 左边的"第几天"，读长日记时跟着滚 */
.entry-head { align-self: start; position: sticky; top: 1.5rem; }

.day {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
  margin: 0;
  line-height: 0.95;
}
.num {
  font-family: var(--round);
  font-size: 3.4rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}
.num.long { font-size: 2.6rem; }
.suf { font-size: 1rem; font-weight: 700; }
.before { font-size: 1rem; font-weight: 700; color: var(--muted); }

.date {
  display: flex;
  flex-direction: column;
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.entry-main h1,
.entry-main h2 {
  margin: 0 0 0.6rem;
  font-size: 1.55rem;
  line-height: 1.35;
  font-weight: 700;
}
.entry-main h2 a {
  color: inherit;
  text-decoration: none;
}
.entry-main h2 a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}
.entry-main h1 {
  margin-top: 0.2rem;
}
/* 正文：Markdown 排版 */
.text > * { max-width: 34em; }
.text p { margin: 0 0 1em; }
.text p:last-child { margin-bottom: 0; }
.text h2, .text h3 {
  margin: 1.7em 0 0.55em;
  font-weight: 700;
  line-height: 1.3;
}
.text h2 { font-size: 1.35rem; }
.text h3 { font-size: 1.12rem; }
.text h2:first-child, .text h3:first-child { margin-top: 0; }
.text ul, .text ol { margin: 0 0 1em; padding-left: 1.4em; }
.text li { margin: 0.2em 0; }
.text blockquote {
  margin: 1.2em 0;
  padding-left: 1em;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.text a { color: var(--ink); text-underline-offset: 0.25em; text-decoration-thickness: 2px; }
.text code {
  padding: 0.1em 0.35em;
  font-size: 0.9em;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  border-radius: 0.25em;
}
.text pre {
  margin: 0 0 1em;
  padding: 1em;
  overflow-x: auto;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 0.4em;
}
.text pre code { padding: 0; background: none; }
.text hr { margin: 2em 0; border: 0; border-top: 1.5px solid var(--line); }
.text img { max-width: 100%; height: auto; border-radius: 0.4rem; }

/* 照片：1 张按原比例，2–4 张拼格，多于 4 张在灯箱里看 */
.photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.ph {
  position: relative;
  display: block;
  padding: 0;
  overflow: hidden;
  background: var(--ph);
  border: 0;
  border-radius: 0.4rem;
  cursor: zoom-in;
}
.ph img { display: block; width: 100%; height: 100%; object-fit: cover; }

.ph[hidden] { display: none; }

.n1 { grid-template-columns: 1fr; }
.n1 .ph { aspect-ratio: auto; }
.n1 .ph img { height: auto; }
.n2 .ph { aspect-ratio: 4 / 5; }
.n3 .ph, .n4 .ph { aspect-ratio: 1; }
.n3 .ph:first-child { grid-column: 1 / -1; aspect-ratio: 3 / 2; }

.more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--round);
  font-size: 1.9rem;
  font-weight: 800;
  color: #fff;
  background: rgba(18, 23, 27, 0.62);
}

.etags {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
}
.hash {
  padding: 0.25rem 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  text-decoration: none;
}
.hash:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 0.25em; }

/* 标签页、翻页、上一篇/下一篇 */
.term-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 2rem;
}
.term-head h1 { margin: 0; font-size: 1.5rem; line-height: 1.3; }
.term-head p { margin: 0; font-size: 0.95rem; color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2.5rem 0 0;
}
.pager-info { font-size: 0.9rem; color: var(--muted); }

.post-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 2.5rem; }

.back { margin: 0 0 1.2rem; font-size: 0.9rem; }
.back a { color: var(--muted); text-decoration: none; }
.back a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 0.25em; }

.notice {
  max-width: 34em;
  margin: 0;
  padding: 1.25rem;
  border: 1.5px dashed var(--ink);
  border-radius: 0.5rem;
}
.notice strong { display: block; margin-bottom: 0.25rem; }
.notice code { font-size: 0.9em; }

@media (max-width: 47.99rem) {
  .entry { display: block; padding-bottom: 3rem; }
  .entry-head {
    position: static;
    display: flex;
    align-items: baseline;
    gap: 0.9rem;
    margin-bottom: 0.75rem;
  }
  .num { font-size: 2.6rem; }
  .num.long { font-size: 2.2rem; }
  .date { flex-direction: row; gap: 0.5rem; margin: 0; }
  .entry-main h1, .entry-main h2 { font-size: 1.4rem; }
}

/* ───────── 灯箱 ───────── */
#lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
}
#lightbox::backdrop { background: #0E1C14; }
#lightbox :focus-visible { outline-color: #fff; }

.lb {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  padding: 1rem var(--gutter);
}
.lb-stage { min-height: 0; touch-action: pan-y; }
.lb-img { display: block; width: 100%; height: 100%; object-fit: contain; }

.lb-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 1rem;
}
.lb-cap { margin: 0; font-size: 0.95rem; line-height: 1.5; }
.lb-cap span { margin-left: 0.75rem; opacity: 0.7; font-family: var(--round); }
.lb-actions { display: flex; gap: 0.5rem; }
.lb-btn {
  min-height: 2.5rem;
  padding: 0 1.1rem;
  font: inherit;
  font-size: 0.92rem;
  color: #fff;
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  cursor: pointer;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.14); }
.lb-btn[hidden] { display: none; }

/* ───────── 404 ───────── */
.lost {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.5rem;
  max-width: 34rem;
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--gutter);
}
.lost-num {
  margin: 0;
  font-family: var(--round);
  font-size: 7rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
}
.lost h1 { margin: 0; font-size: 1.6rem; }
.lost p { margin: 0 0 1rem; }
