/* ==========================================================================
   心理动力学文献精读 —— 学术严谨风样式
   配色沿用原文的深蓝系（#12314F / #1F4E79），保证与公众号视觉延续
   ========================================================================== */

:root {
  --paper:      #FBFAF7;
  --card:       #FFFFFF;
  --ink:        #1C1A17;
  --ink-2:      #5C574F;
  --ink-3:      #8B857A;
  --accent:     #1F4E79;
  --accent-2:   #12314F;
  --rule:       #E3DED4;
  --rule-soft:  #EFEBE3;
  --quote-bg:   #F5F2EB;

  --serif: Georgia, "Noto Serif SC", "Source Han Serif SC", "Songti SC",
           "STSong", SimSun, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
           "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --measure: 38rem;
  --gap: 2rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.narrow { max-width: calc(var(--measure) + 3rem); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 站头 ---------- */

.site-head {
  padding: 4.5rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.kicker {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.9rem;
}
.site-title {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 4.5vw, 2.6rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.01em;
  margin: 0 0 0.85rem;
  color: var(--accent-2);
}
/* 站头题词：温尼科特引语（中文译文 + 英文原文 + 出处） */
.site-quote {
  margin: 0.35rem 0 2rem;
  padding-left: 1.15rem;
  border-left: 2px solid var(--accent);
  max-width: 46rem;
}
.site-quote blockquote { margin: 0; }
.site-quote .quote-cn {
  font-family: var(--serif);
  font-size: 1.24rem;
  font-weight: 500;
  line-height: 1.7;
  color: var(--accent-2);
  margin: 0;
}
.site-quote .quote-en {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--ink-2);
  margin: 0.55rem 0 0;
}
.site-quote .quote-src {
  display: block;
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-top: 0.75rem;
}

/* ---------- 工具条 ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: center;
  padding: 2rem 0 1.25rem;
  border-bottom: 1px solid var(--rule-soft);
}
.search {
  flex: 1 1 18rem;
  min-width: 12rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-on {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}

.count {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin: 1.1rem 0 0;
}

/* ---------- 文章列表 ---------- */

.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule-soft);
  margin-bottom: 5rem;
}
.card {
  display: block;
  color: inherit;
  padding: 1.75rem 1.5rem 1.6rem 0;
  border-bottom: 1px solid var(--rule-soft);
  transition: opacity 0.15s;
}
.card:hover { text-decoration: none; }
.card:hover .card-title { color: var(--accent); }
.card[hidden] { display: none; }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.badge {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(31, 78, 121, 0.08);
  border-radius: 2px;
  padding: 0.15rem 0.5rem;
}
.card-head time {
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.card-title {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 500;
  line-height: 1.5;
  margin: 0 0 0.6rem;
  color: var(--ink);
  transition: color 0.15s;
}
.card-sum {
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--ink-2);
  margin: 0;
}
.tag {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.1rem 0.45rem;
}
.empty {
  font-family: var(--sans);
  color: var(--ink-3);
  padding: 3rem 0;
  text-align: center;
}

/* ---------- 主页：检索入口 ---------- */

.hero-search {
  display: flex;
  margin-top: 2rem;
  max-width: 34rem;
}
.hero-search input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-right: none;
  border-radius: 2px 0 0 2px;
  padding: 0.7rem 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.hero-search input:focus { border-color: var(--accent); }
.hero-search input::placeholder { color: var(--ink-3); }
.hero-search button {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--accent-2);
  border: 1px solid var(--accent-2);
  border-radius: 0 2px 2px 0;
  padding: 0 1.3rem;
  cursor: pointer;
  transition: background 0.15s;
}
.hero-search button:hover { background: var(--accent); border-color: var(--accent); }

.hub-lead {
  font-family: var(--sans);
  font-size: 0.84rem;
  color: var(--ink-3);
  margin: 2.5rem 0 0;
}

.hub { margin-bottom: 4.5rem; }

.hub-group {
  padding: 1.8rem 0;
  border-top: 1px solid var(--rule-soft);
}
.hub-head {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.hub-name {
  font-family: var(--serif);
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-2);
  margin: 0;
}
.hub-en {
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hub-note {
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.75;
  color: var(--ink-3);
  margin: 0.4rem 0 0;
  max-width: 22rem;
}
.hub-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.95rem;
}

/* 关键词入口 */
.topic {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-family: var(--sans);
  font-size: 0.84rem;
  color: var(--ink-2);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.32rem 0.7rem;
  transition: all 0.15s;
}
.topic:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}
.topic-n { font-size: 0.67rem; color: var(--ink-3); }
.topic:hover .topic-n { color: var(--accent); }

@media (min-width: 820px) {
  .hub-group {
    display: grid;
    grid-template-columns: 12.5rem minmax(0, 1fr);
    column-gap: 2.5rem;
  }
  .hub-head   { grid-column: 1; grid-row: 1; }
  .hub-note   { grid-column: 1; grid-row: 2; }
  .hub-chips  { grid-column: 2; grid-row: 1 / span 2; align-content: start; margin-top: 0; }
}

/* 最近更新 */
.latest { margin-bottom: 5rem; }
.latest-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--rule);
}
.latest-head h2 {
  font-family: var(--serif);
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 0;
}
.more { font-family: var(--sans); font-size: 0.8rem; color: var(--ink-3); }
.more:hover { color: var(--accent); }
.list-latest { margin-bottom: 0; border-top: none; }

/* ---------- 文章库页 ---------- */

.browse-head {
  padding: 3.5rem 0 2rem;
  border-bottom: 1px solid var(--rule);
}
.browse-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3.6vw, 2rem);
  font-weight: 500;
  color: var(--accent-2);
  margin: 1.25rem 0 0.7rem;
}
.browse-sub {
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--ink-2);
  margin: 0;
  max-width: 46rem;
}

.filters { padding: 1.6rem 0 0.4rem; }
.fgroup {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.fgroup-name {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}
@media (min-width: 820px) {
  .fgroup {
    grid-template-columns: 8rem minmax(0, 1fr);
    gap: 0 1.5rem;
    align-items: start;
  }
  .fgroup-name { padding-top: 0.36rem; }
}
.chip i {
  font-style: normal;
  font-size: 0.68em;
  color: var(--ink-3);
  margin-left: 0.35rem;
}
.chip.is-on i { color: rgba(255, 255, 255, 0.72); }

.browse-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.6rem 0 0.3rem;
}
.browse-bar .count { margin: 0; }
.reset {
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.26rem 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.reset:hover { border-color: var(--accent); color: var(--accent); }

/* 标签在文章页是可点的入口 */
a.tag { color: var(--ink-3); }
a.tag:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

/* 文末「本篇涉及」 */
.topics-block {
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule-soft);
}
.topics-h {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 1rem;
}
.ts-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}
.ts-g {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--ink-3);
  min-width: 6.5rem;
}

/* ---------- 文章页 ---------- */

.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 50;
}

.post-head {
  padding: 3.5rem 0 2rem;
  border-bottom: 1px solid var(--rule);
}
.back {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-3);
  margin-bottom: 1.75rem;
}
.back:hover { color: var(--accent); }
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.post-meta time {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.post-title {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3.8vw, 2.05rem);
  font-weight: 500;
  line-height: 1.45;
  margin: 0 0 0.9rem;
  color: var(--accent-2);
  letter-spacing: 0.005em;
}
.post-sum {
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--ink-2);
  margin: 0;
}

.article-layout {
  display: block;
  padding-top: 3rem;
  padding-bottom: 4rem;
}

/* 正文排版 */

.article { max-width: var(--measure); }

.article > p,
.article > ul,
.article > ol {
  font-size: 1.06rem;
  line-height: 1.95;
  margin: 0 0 1.5rem;
  text-align: justify;
  text-justify: inter-ideograph;
}
.article > p:first-of-type::first-letter { /* 学术正文不加首字下沉 */ }

.article h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--accent-2);
  margin: 3rem 0 1.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule-soft);
  scroll-margin-top: 1.5rem;
}
.article h2:first-child { margin-top: 0; border-top: none; padding-top: 0; }
.article h3 {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  margin: 2.25rem 0 1rem;
}
.article h4 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-2);
  margin: 1.75rem 0 0.75rem;
}

.article strong { font-weight: 600; color: var(--accent-2); }
.article em { font-style: italic; color: var(--accent); }
.article del { color: var(--ink-3); }

.article a {
  color: var(--accent);
  border-bottom: 1px solid rgba(31, 78, 121, 0.3);
}
.article a:hover { text-decoration: none; border-bottom-color: var(--accent); }

.article code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--quote-bg);
  border: 1px solid var(--rule-soft);
  border-radius: 2px;
  padding: 0.1em 0.35em;
}
.article pre {
  background: #F7F5F0;
  border: 1px solid var(--rule-soft);
  border-radius: 3px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 0 0 1.5rem;
}
.article pre code {
  background: none; border: none; padding: 0;
  font-size: 0.85rem; line-height: 1.7;
}

.article blockquote {
  margin: 1.75rem 0;
  padding: 0.25rem 0 0.25rem 1.35rem;
  border-left: 2px solid var(--accent);
  background: var(--quote-bg);
  border-radius: 0 2px 2px 0;
}
.article blockquote p {
  font-size: 0.99rem;
  line-height: 1.9;
  color: var(--ink-2);
  margin: 0;
  padding: 0.7rem 1rem 0.7rem 0;
  text-align: left;
}

.article ul, .article ol { padding-left: 1.5rem; }
.article li { margin-bottom: 0.55rem; line-height: 1.9; font-size: 1.02rem; }
.article li::marker { color: var(--ink-3); }

.article hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem auto;
  width: 30%;
}

/* 表格 */
.article .tw {
  overflow-x: auto;
  margin: 0 0 1.75rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.article table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.7;
}
.article th {
  background: #F4F1EA;
  font-weight: 600;
  color: var(--accent-2);
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.article td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink-2);
  vertical-align: top;
}
.article tbody tr:last-child td { border-bottom: none; }
.article tbody tr:nth-child(even) { background: #FCFBF8; }

.article img { max-width: 100%; height: auto; border-radius: 2px; }

/* 侧栏目录 */
.sidebar { display: none; }
.toc {
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.7;
}
.toc-h {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.85rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--rule-soft);
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: t; }
.toc li { counter-increment: t; margin-bottom: 0.5rem; }
.toc li::before {
  content: counter(t) ".";
  color: var(--ink-3);
  margin-right: 0.45rem;
  font-size: 0.72rem;
}
.toc a { color: var(--ink-2); display: inline; }
.toc a:hover { color: var(--accent); }
.toc a.is-active { color: var(--accent); font-weight: 600; }

/* 上下篇 */
.pager {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding-bottom: 5rem;
  border-top: 1px solid var(--rule);
  padding-top: 2rem;
}
.pn {
  display: block;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--card);
  transition: border-color 0.15s;
}
.pn:hover { text-decoration: none; border-color: var(--accent); }
.pn span {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-bottom: 0.35rem;
}
.pn strong {
  font-family: var(--serif);
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink);
}
.pn.next { text-align: right; }

/* 页脚 */
.site-foot {
  border-top: 1px solid var(--rule);
  padding: 2.5rem 0 3.5rem;
  text-align: center;
}
.site-foot p {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.9;
}

/* ---------- 宽屏 ---------- */

@media (min-width: 1100px) {
  .article-layout {
    display: grid;
    grid-template-columns: minmax(0, var(--measure)) 13rem;
    gap: 4rem;
    max-width: 62rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  .sidebar { display: block; }
  .toc { position: sticky; top: 2.5rem; max-height: calc(100vh - 5rem); overflow-y: auto; }
  /* 文末主题块落在正文列下方，与正文左边界对齐 */
  .topics-block { grid-column: 1; }
  .pager { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .site-head { padding: 3rem 0 2rem; }
  .article > p, .article > ul, .article > ol { font-size: 1.02rem; text-align: left; }
}

/* ---------- 深色模式 ---------- */

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #16151A;
    --card:      #1D1C22;
    --ink:       #E8E4DC;
    --ink-2:     #ADA79C;
    --ink-3:     #7C766C;
    --accent:    #8AB4DC;
    --accent-2:  #C6D8EA;
    --rule:      #33313A;
    --rule-soft: #29272F;
    --quote-bg:  #201F26;
  }
  .article th { background: #232228; color: var(--accent-2); }
  .article tbody tr:nth-child(even) { background: #1B1A20; }
  .article pre { background: #1B1A20; }
  .badge { background: rgba(138, 180, 220, 0.12); }
  .chip.is-on { color: #16151A; }
  .chip.is-on i { color: rgba(22, 21, 26, 0.72); }
  .hero-search button { color: #16151A; }
  .topic { background: var(--card); }
}

/* ---------- 打印 ---------- */

@media print {
  .site-head, .toolbar, .pager, .sidebar, .progress, .back, .site-foot,
  .hub, .hub-lead, .latest, .filters, .browse-bar, .reset,
  .topics-block, .hero-search, .browse-head .back { display: none; }
  body { background: #fff; font-size: 11.5pt; }
  .article > p { text-align: justify; }
  .article h2 { border-top: none; }
}
