@media (max-width:640px) {
  .site-header { min-height:64px; padding:13px 18px; }
  .header-actions { gap:6px; }
  .admin-badge { display:none; }
  .button { padding:7px 10px; font-size:.78rem; }
  main { padding:64px 18px 0; }
  .intro { padding:76px 0 28px; }
  .intro h1 { font-size:clamp(2.75rem,14vw,4.4rem); }
  .intro-copy { margin-top:22px; font-size:.92rem; }
  .posts-section { padding-bottom:76px; }
  .section-heading { min-height:66px; }
  .post-card { padding:23px 0 25px; }
  .post-card h3 { font-size:1.3rem; }
  .post-details { padding-top:18px; }
  footer { min-height:96px; padding:26px 18px; flex-direction:row; align-items:flex-start; gap:18px; }
  .footer-identity { width:50%; font-size:.72rem; }
  .dialog-card { padding:30px 22px 24px; }
}
@media (prefers-reduced-motion:reduce) {
  html { scroll-behavior:auto; }
  *,*::before,*::after { transition:none!important; }
}

/* UI v3 — quieter intro and footer */
.intro {
  padding: 82px 0 42px;
  text-align: center;
}

.intro h1 {
  max-width: none;
  font-size: clamp(1.8rem, 4.6vw, 3.4rem);
  line-height: 1.2;
  letter-spacing: -.035em;
}

.intro-copy {
  margin-top: 18px;
  font-size: .9rem;
}

.footer-identity {
  font-size: .68rem;
  font-weight: 400;
  color: var(--muted);
}

@media (max-width: 640px) {
  .intro {
    padding-top: 68px;
  }

  .intro h1 {
    font-size: clamp(1.7rem, 7.4vw, 2.15rem);
  }

  .intro-copy {
    font-size: .82rem;
  }

  footer {
    gap: 18px;
  }

  .footer-identity {
    font-size: .64rem;
  }
}


/* UI v6 — 分類樹沿用原站的直角、線條和強調色。 */
.category-heading > span { letter-spacing:.12em; }
.category-link { font-size:.84rem; }
.category-link:hover { background:var(--accent-soft); }
.category-expander:focus-visible,.category-link:focus-visible,
.category-node-actions button:focus-visible { outline:2px solid var(--ink); outline-offset:2px; }
@media (max-width:640px) {
  .category-section { padding:14px 0 18px; }
  .category-heading { gap:8px; }
  .category-link { font-size:.8rem; }
  .category-list .category-list { margin-left:12px; padding-left:8px; }
  .category-node-actions button { padding:3px 5px; }
  .category-form-actions { justify-content:space-between; }
}

/* 手機文章工具列：能折行、不溢出對話框。 */
@media (max-width:640px) {
  #editor-dialog { width:96vw; max-height:94dvh; }
  #editor-dialog .dialog-card { padding:30px 15px 20px; }
  .rich-mode button { padding:10px 6px; font-size:.77rem; }
  .rich-toolbar { gap:2px; padding:6px; }
  .rich-toolbar button { min-width:31px; min-height:36px; padding:4px 6px; }
  .rich-toolbar-divider { margin:0 2px; }
  .rich-surface,.rich-source { min-height:36dvh; max-height:52dvh; padding:13px; }
  .editor-insert-dialog .dialog-card { padding:30px 20px 22px; }
}


/* UI v10 — 固定 header + 上方 sticky 分類樹。保留原本父子樹結構。 */
.posts-column { min-width:0; }

.category-section {
  position:sticky;
  top:72px;
  z-index:900;
  max-height:min(42dvh,360px);
  overflow-y:auto;
  overflow-x:hidden;
  padding:14px 0 16px;
  border-right:0;
  border-bottom:1px solid var(--ink);
  background:var(--paper);
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}

.category-heading {
  position:sticky;
  top:0;
  z-index:2;
  margin-bottom:10px;
  padding:2px 0 6px;
  background:var(--paper);
}

.category-tree {
  overflow-x:auto;
  overflow-y:visible;
  padding-right:4px;
}

/* 分類仍然是原本的樹：箭頭、縮排、子分類全部保留。 */
.category-list { min-width:0; }
.category-row { min-width:0; }

/* fixed header + sticky 分類高度會變動，JS 會依實際高度計算文章定位。 */
.post-card,
#posts { scroll-margin-top:12px; }

@media (max-width:640px) {
  .site-header { gap:12px; }
  .site-title { font-size:.82rem; }
  .site-title a { display:block; white-space:nowrap; }

  .category-section {
    top:64px;
    max-height:min(40dvh,300px);
    padding:11px 0 13px;
  }

  .category-heading {
    align-items:center;
    flex-direction:row;
    margin-bottom:8px;
  }

  .category-tree { overflow-x:auto; }
  .category-row { gap:4px; }
  .category-expander { flex-basis:24px; min-width:24px; width:24px; }
  .category-link { padding:5px 6px; overflow-wrap:anywhere; }
  .category-count { font-size:.68rem; }
  .category-list .category-list { margin-left:12px; padding-left:8px; }
}
