:root {
  --bg: #f5efe7;
  --surface: rgba(255, 251, 247, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-deep: #1a2630;
  --text: #18232c;
  --muted: #5c6870;
  --line: rgba(24, 35, 44, 0.1);
  --accent: #126d67;
  --accent-soft: rgba(18, 109, 103, 0.11);
  --accent-2: #b75a3d;
  --accent-2-soft: rgba(183, 90, 61, 0.12);
  --shadow: 0 26px 70px rgba(24, 35, 44, 0.08);
  --max: 1160px;
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    linear-gradient(180deg, #fffaf5 0%, #f6ede3 54%, #efe3d6 100%);
}

a {
  color: var(--accent);
}

img {
  display: block;
  max-width: 100%;
}

.shell {
  width: min(calc(100% - 2rem), var(--max));
  margin: 0 auto;
  position: relative;
}

.paper-grain {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 38px 38px;
  opacity: 0.16;
  pointer-events: none;
  z-index: -3;
}

.paper-light {
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 999px;
  filter: blur(28px);
  opacity: 0.35;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.paper-light--left {
  top: -6rem;
  left: -6rem;
  background: rgba(18, 109, 103, 0.18);
}

.paper-light--right {
  top: 5rem;
  right: -4rem;
  background: rgba(183, 90, 61, 0.16);
}

.site-header,
.site-footer,
.hero,
.article-grid,
.home-grid {
  display: grid;
  gap: 1.35rem;
}

.site-header {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 1.4rem 0 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.95rem;
  text-decoration: none;
  color: inherit;
}

.brand__mark {
  width: 3rem;
  height: 3rem;
  border-radius: 0.9rem;
  box-shadow: 0 12px 28px rgba(18, 109, 103, 0.22);
}

.brand__copy strong {
  display: block;
  font-size: 1.02rem;
}

.brand__copy small {
  display: block;
  color: var(--muted);
}

.site-nav,
.site-footer__links,
.hero__cta,
.article-meta,
.post-card__meta {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.site-nav a,
.site-footer__links a {
  text-decoration: none;
  color: inherit;
  font-weight: 600;
}

.site-nav a {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(24, 35, 44, 0.08);
}

.hero {
  grid-template-columns: 1fr;
  align-items: start;
  padding: 0.8rem 0 2.3rem;
}

.hero__copy,
.post-card,
.sidebar-box,
.article-note,
.ad-slot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.6rem;
  box-shadow: var(--shadow);
}

.hero__copy,
.sidebar-box,
.article-note,
.ad-slot {
  padding: 1.45rem;
}

.hero__copy {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 249, 242, 0.88)),
    radial-gradient(circle at right top, rgba(18, 109, 103, 0.08), transparent 36%);
}

.hero__copy h1,
.section-heading h2,
.page-intro h1,
.article-hero h1 {
  margin: 0.45rem 0 1rem;
  line-height: 1.05;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  letter-spacing: -0.02em;
}

.hero__copy h1 {
  max-width: 15ch;
  font-size: clamp(2.5rem, 5vw, 4.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.hero__copy p,
.page-intro p,
.article-hero p,
.post-card p,
.sidebar-box p,
.article-note p,
.site-footer p {
  color: #36434c;
  line-height: 1.9;
}

.eyebrow {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.hero__cta {
  margin-top: 1.45rem;
}

.hero__copy--wide {
  padding: 1.8rem 1.8rem 1.6rem;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.62fr);
  gap: clamp(1.25rem, 3vw, 2.4rem);
  align-items: center;
}

.hero-main {
  min-width: 0;
}

.hero-side {
  min-width: 0;
  padding-left: 1.4rem;
  border-left: 1px solid rgba(24, 35, 44, 0.08);
}

.hero-summary__intro p {
  margin: 0.45rem 0 0.85rem;
  line-height: 1.7;
  color: #4a5861;
}

.hero-stat-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.25rem;
}

.hero-stat {
  display: flex;
  flex-direction: column;
}

.hero-stat__num {
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.hero-stat__label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
  letter-spacing: 0.04em;
}


.hero-side__divider {
  height: 1px;
  margin: 1.1rem 0 1.2rem;
  background: rgba(24, 35, 44, 0.08);
}

.topic-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.topic-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(24, 35, 44, 0.12);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.topic-links a:hover {
  background: var(--accent-soft);
  border-color: rgba(18, 109, 103, 0.25);
  color: var(--accent);
}

.hero-summary__intro--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.eyebrow-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.03em;
}

.eyebrow-link:hover {
  text-decoration: underline;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.92rem 1.18rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid rgba(24, 35, 44, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
}

.button--primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.home-grid,
.article-shell {
  margin-bottom: 3rem;
}

.section-heading,
.page-intro {
  margin-bottom: 1.15rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
}

.see-all-link {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  transition: opacity 0.15s;
}

.see-all-link:hover {
  opacity: 0.72;
}

.card-grid {
  display: grid;
  gap: 1.1rem;
}

.home-grid {
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 19.5rem);
  grid-template-areas:
    "heading ."
    "posts sidebar";
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.home-grid .section-heading {
  grid-area: heading;
}

.home-grid .card-grid--latest {
  grid-area: posts;
}

.home-grid .sidebar {
  grid-area: sidebar;
}

.card-grid--latest,
.card-grid--archive {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sidebar {
  display: grid;
  gap: 1rem;
  align-content: start;
  min-width: 0;
  max-width: 100%;
}

.sidebar-box--dense {
  background: rgba(255, 255, 255, 0.74);
}

.simple-list {
  margin: 0.9rem 0 0;
  padding-left: 1rem;
  color: #36434c;
}

.simple-list li {
  margin-bottom: 0.55rem;
}

.simple-list a {
  color: var(--accent-2);
  text-decoration: none;
}

.post-card {
  display: grid;
  gap: 0.9rem;
  padding: 1.42rem;
  min-width: 0;
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}

.post-card:hover {
  box-shadow: 0 8px 36px rgba(18, 109, 103, 0.14);
  border-color: rgba(18, 109, 103, 0.28);
  transform: translateY(-2px);
}

.post-card h3 {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.22rem);
  line-height: 1.3;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  overflow-wrap: break-word;
  word-break: break-word;
}

.post-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-card__meta,
.article-meta {
  align-items: center;
  font-size: 0.92rem;
  color: #65737d;
}

.pill,
.article-meta a {
  display: inline-flex;
  align-items: center;
  padding: 0.34rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.post-card > p {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.9rem;
  line-height: 1.7;
}

.post-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.post-card__link {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.archive-search {
  margin-top: 1.25rem;
}

.archive-search input {
  width: 100%;
  padding: 0.85rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #fff;
  font: inherit;
  box-sizing: border-box;
}

.search-results {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.search-results a {
  display: block;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.article-grid {
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
}

.article-hero {
  max-width: 54rem;
  margin-bottom: 1.5rem;
}

.article-content {
  max-width: 54rem;
}

.standalone-page {
  margin-bottom: 3rem;
}

.article-rail {
  display: grid;
  gap: 1rem;
  position: sticky;
  top: 1rem;
}

.article-note strong {
  display: block;
  line-height: 1.55;
  margin-top: 0.35rem;
}


.post-reactions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.68);
}

.post-reactions strong {
  display: block;
  margin-top: 0.25rem;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 1.05rem;
  line-height: 1.35;
  color: var(--text);
}

.post-reactions__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.post-reactions__stat {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.post-reactions__like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid rgba(24, 35, 44, 0.12);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.post-reactions__like:hover {
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
  color: var(--accent-2);
}

.post-reactions__like.is-liked {
  border-color: transparent;
  background: var(--accent-2-soft);
  color: var(--accent-2);
}

.post-reactions__like:disabled {
  cursor: default;
  opacity: 0.72;
}

@media (max-width: 980px) {
  .post-reactions {
    align-items: flex-start;
    flex-direction: column;
  }
  .post-reactions__actions {
    width: 100%;
  }
}

.prose p,
.prose li {
  font-size: 1.08rem;
  line-height: 2;
}

.prose h2,
.prose h3 {
  margin-top: 2.2rem;
  line-height: 1.15;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  overflow-wrap: break-word;
  word-break: break-word;
}

.code-wrap {
  position: relative;
  margin: 1.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 1rem;
}

.code-wrap pre {
  margin: 0;
  overflow-x: visible;
  border-radius: 0;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem 1rem 1rem 1rem;
  border-radius: 1rem;
  background: var(--surface-deep);
  color: #f8fafc;
}

.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.copy-btn.is-copied {
  background: rgba(18,109,103,0.5);
  color: #fff;
  border-color: transparent;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
}

.prose table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
  line-height: 1.6;
}

.prose th,
.prose td {
  padding: 0.65rem 1.1rem;
  border: 1px solid rgba(24, 35, 44, 0.12);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  min-width: 8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prose td {
  background: rgba(255, 255, 255, 0.85);
}

.prose tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.55);
}

.prose th {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.95rem 1rem;
  border-left: 4px solid var(--accent-2);
  background: var(--accent-2-soft);
  overflow-wrap: break-word;
  word-break: break-word;
}

.ad-slot__meta {
  margin-bottom: 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6f7b83;
}

.ad-slot {
  overflow: hidden;
  max-width: 100%;
}

.adsbygoogle {
  max-width: 100% !important;
}

.ad-slot__placeholder {
  min-height: 120px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(24, 35, 44, 0.04);
  color: var(--muted);
}

.site-footer {
  grid-template-columns: 1fr auto;
  align-items: start;
  padding: 2.15rem 0 3rem;
  margin-top: 4rem;
  border-top: 1px solid var(--line);
}

.site-footer__intro {
  max-width: 38rem;
}

/* ── Category filter bar ── */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 auto 2rem;
  max-width: var(--max);
  padding: 0 1.5rem;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.category-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.category-pill--active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.category-pill--active:hover {
  background: var(--accent);
  color: #fff;
}

.category-pill__count {
  font-size: 0.75rem;
  opacity: 0.75;
  font-weight: 400;
}

.category-pill--active .category-pill__count {
  opacity: 0.85;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tool-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(18, 109, 103, 0.1);
}

.tool-card__icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.tool-card__title {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.tool-card__desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

@media (max-width: 980px) {
  .site-header,
  .site-footer {
    grid-template-columns: 1fr;
  }

  /* article-grid 改用 block 排版，確保完全單欄不溢出 */
  .article-grid {
    display: block;
  }

  .article-rail {
    margin-top: 1.5rem;
  }

  .card-grid--latest,
  .card-grid--archive {
    grid-template-columns: 1fr;
  }

  /* home-grid 改用 block 排版，確保完全單欄不溢出 */
  .home-grid {
    display: block;
  }

  .home-grid .section-heading {
    margin-bottom: 1.15rem;
  }

  .home-grid .card-grid--latest {
    margin-bottom: 1.35rem;
  }

  .hero-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hero-side {
    padding-left: 0;
    padding-top: 1.2rem;
    border-left: 0;
    border-top: 1px solid rgba(24, 35, 44, 0.08);
  }

  .article-rail {
    position: static;
  }

  /* 文章標題強制換行 */
  .article-hero h1 {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* 內文容器保護 */
  .article-content {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(calc(100% - 1.2rem), var(--max));
  }

  .site-nav {
    gap: 0.55rem;
  }

  .hero__copy h1 {
    max-width: 100%;
    font-size: clamp(2.15rem, 10vw, 3.2rem);
  }

  .hero__copy,
  .hero__copy--wide {
    padding: 1.25rem;
  }

  .button {
    width: 100%;
  }

  .hero__cta {
    gap: 0.65rem;
  }

  /* 手機版文章卡片單欄 */
  .card-grid--latest,
  .card-grid--archive {
    grid-template-columns: 1fr;
  }

  /* 防止 hero-layout 側欄在極小螢幕撐開 */
  .hero-layout {
    grid-template-columns: 1fr;
  }

  /* 卡片 meta 換行時不超出 */
  .post-card__meta {
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }

  /* 卡片標題字體縮小 */
  .post-card h3 {
    font-size: clamp(1rem, 5vw, 1.4rem);
  }
}

.article-inline-ad {
  margin-top: 3rem;
}

.tool-ad-wrap {
  max-width: 860px;
  margin: 2.5rem auto 0;
}
