/* ═══════════════════════════════════════════════
   西方文学讲义 · 共享样式表
   ═══════════════════════════════════════════════ */

/* ─── CSS VARIABLES ─── */
:root {
  --bg:       #0c0f1a;
  --surface:  #111624;
  --surface2: #171d2e;
  --gold:     #f0f0f0;
  --gold-dim: #4a6fa0;
  --text:     #e8eaf0;
  --muted:    #6a7a9a;
  --line:     rgba(200,220,255,0.12);

  --c1: #6b9fd4;
  --c2: #4a80c0;
  --c3: #e05252;
  --c4: #7ab0e0;
  --c5: #d94040;
  --c6: #2a65b8;
  --c7: #eeeef4;
  --c8: #c03030;

  --sidebar-w:   260px;
  --titlebar-h:  36px;
  --notes-w:     400px;
  --content-max: 820px;
}

[data-theme="light"] {
  --bg:       #f4f1ea;
  --surface:  #ede9df;
  --surface2: #e5e0d4;
  --gold:     #1a1814;
  --gold-dim: #2a5090;
  --text:     #1e1c18;
  --muted:    #6a6050;
  --line:     rgba(0,0,0,0.1);
}

/* ─── RESET ─── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif SC', serif;
  font-weight: 300;
  line-height: 1.8;
  overflow-x: hidden;
  /* 三栏布局：titlebar fixed，body 以下区域由 #gl-workspace 承担 */
}

/* ─── GRAIN OVERLAY ─── */
body::before {
  content:'';
  position:fixed; inset:0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events:none; z-index:9999; opacity:.5;
}

/* ─── TITLEBAR（Obsidian 风格顶部栏）─── */
#gl-titlebar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--titlebar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  /* 三色条作为顶部 border-top */
  border-top: 3px solid transparent;
  border-image: linear-gradient(to right,
    #002395 0%, #002395 33.3%,
    #ffffff 33.3%, #ffffff 66.6%,
    #ED2939 66.6%, #ED2939 100%
  ) 1;
  z-index: 10000;
  display: flex;
  align-items: center;
  user-select: none;
}

/* ── titlebar 左区：宽度与侧边栏对齐，放折叠按钮 ── */
.titlebar-left {
  display: flex;
  align-items: center;
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  padding: 0 .5rem;
  gap: .15rem;
  transition: width .3s cubic-bezier(.16,1,.3,1);
  overflow: hidden;
}
/* 侧边栏收起时，左区收缩到仅容纳按钮 */
.titlebar-left.collapsed {
  width: 44px;
}

/* ── titlebar 中区：可滚动 tab 栏 ── */
.titlebar-center {
  flex: 1;
  display: flex;
  align-items: stretch;
  height: 100%;
  overflow: hidden;
  min-width: 0;
}

/* Tab 列表容器：横向滚动 */
#titlebar-tabs {
  display: flex;
  align-items: stretch;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge */
  gap: 0;
}
#titlebar-tabs::-webkit-scrollbar { display: none; }

/* 单个 Tab */
.tb-tab {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 .55rem 0 .65rem;
  gap: .32rem;
  border-right: 1px solid var(--line);
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  transition: background .15s;
  max-width: 200px;
  min-width: 60px;
}
.tb-tab:first-child { border-left: 1px solid var(--line); }
.tb-tab:hover { background: var(--surface2); }
.tb-tab.active {
  background: var(--bg);
  border-bottom: 2px solid var(--gold-dim);
}

/* Tab 前的小圆点 */
.tb-tab-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background .15s;
}
.tb-tab.active .tb-tab-dot { background: var(--gold-dim); }

/* Tab 标题链接 */
.tb-tab-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: .82rem;
  color: var(--muted);
  letter-spacing: .04em;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  line-height: 1;
  transition: color .15s;
}
.tb-tab.active .tb-tab-title { color: var(--text); }
.tb-tab-title:hover { color: var(--gold); }

/* Tab 关闭按钮 */
.tb-tab-close {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  font-size: .82rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
  padding: 0;
}
.tb-tab:hover .tb-tab-close { opacity: .7; }
.tb-tab-close:hover { opacity: 1 !important; background: rgba(200,80,80,.2); color: #f08080; }

/* ── titlebar 右区：宽度与 Notes 面板对齐，放 Notes 按钮 ── */
.titlebar-right {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 .4rem;
  gap: .15rem;
  flex-shrink: 0;
  width: var(--notes-w);
  justify-content: flex-end;
  transition: width .3s cubic-bezier(.16,1,.3,1);
  overflow: hidden;
}
/* Notes 面板收起时，右区收缩到仅容纳按钮 */
.titlebar-right.notes-collapsed {
  width: 44px;
}

/* ── 左侧边栏折叠按钮 ── */
#sidebar-focus-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s;
  padding: 0;
}
#sidebar-focus-btn:hover { background: var(--surface2); color: var(--text); }
#sidebar-focus-btn.collapsed { color: #4ade80; }

/* ── 旧版单页 tab（已由 #titlebar-tabs 系统替代，保留兼容）── */
.titlebar-page-tab {
  display: none; /* 已废弃 */
}
.titlebar-page-tab-dot {
  display: none;
}

/* ── 顶部通用按钮 ── */
.titlebar-btn {
  height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  padding: 0 .5rem;
  font-size: .72rem;
  letter-spacing: .1em;
  font-family: 'Cormorant Garamond', serif;
  white-space: nowrap;
  flex-shrink: 0;
}
.titlebar-btn:hover { background: var(--surface2); color: var(--text); }
.titlebar-btn.active { color: #4ade80; }

/* Notes 触发按钮专属 */
#gl-notes-titlebar-btn {
  font-style: italic;
  letter-spacing: .18em;
  height: 100%;
  padding: 0 .9rem;
  border-radius: 0;
}
#gl-notes-titlebar-btn.active {
  background: rgba(74,222,128,.06);
  border-bottom: 2px solid #4ade80;
}
#gl-notes-titlebar-btn .notes-badge {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #4ade80;
  display: none;
  margin-left: .3rem;
  box-shadow: 0 0 4px #4ade80;
}
#gl-notes-titlebar-btn.has-content .notes-badge { display: block; }

/* ─── FRENCH TRICOLOR TOP STRIPE（保留用于不含 titlebar 的页面）─── */
.page-top-stripe {
  position:fixed; top:0; left:0; right:0;
  height:4px; z-index:10001;
  background: linear-gradient(to right,
    #002395 0%, #002395 33.3%,
    #ffffff 33.3%, #ffffff 66.6%,
    #ED2939 66.6%, #ED2939 100%
  );
}
/* 有 titlebar 的页面隐藏独立三色条 */
body.has-titlebar .page-top-stripe { display: none; }

/* ─── THEME TOGGLE（已迁入 titlebar）─── */
#theme-toggle {
  position: fixed;
  top: 1.2rem; right: 1.4rem;
  z-index: 10000;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: 'Cormorant Garamond', serif;
  font-size: .85rem;
  letter-spacing: .12em;
  padding: .4rem .9rem;
  cursor: pointer;
  border-radius: 2px;
  transition: background .25s, color .25s, border-color .25s;
}
#theme-toggle:hover { opacity: .8; }
body.has-titlebar #theme-toggle { display: none; }

/* ─── WORKSPACE（三栏容器）─── */
#gl-workspace {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  padding-top: var(--titlebar-h);
  position: relative;
}

/* ─── SIDEBAR（左栏）─── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  /* 固定在左侧，随滚动保持 */
  position: sticky;
  top: var(--titlebar-h);
  height: calc(100vh - var(--titlebar-h));
  align-self: flex-start;
  transition: width .3s cubic-bezier(.16,1,.3,1),
              opacity .3s,
              border-color .3s;
  z-index: 100;
}
#sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

#sidebar-inner {
  padding: 1.4rem 1.2rem 3rem;
  min-width: var(--sidebar-w);  /* 防止内容随宽度压缩 */
}

/* ─── MAIN CONTENT（中栏，内容居中）─── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;   /* 水平居中内容 */
}

/* 内容居中容器 */
.content-center {
  width: 100%;
  max-width: var(--content-max);
  padding: 0 1.5rem;
}

/* ─── NOTES PANEL（右栏，嵌入式）─── */
#gl-note-panel {
  width: var(--notes-w);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
  /* 固定在右侧，随滚动保持 */
  position: sticky;
  top: var(--titlebar-h);
  height: calc(100vh - var(--titlebar-h));
  align-self: flex-start;
  transition: width .3s cubic-bezier(.16,1,.3,1),
              opacity .3s,
              border-color .3s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}
#gl-note-panel.notes-collapsed {
  width: 0;
  border-left-color: transparent;
  opacity: 0;
  pointer-events: none;
}

/* ─── SIDEBAR COLLAPSE (旧 focus mode 兼容保留)─── */
#sidebar.old-collapsed { transform: translateX(-100%); }
.main-content.sidebar-collapsed { margin-left: 0; }

/* ─── SIDEBAR TOGGLE BUTTON (mobile) ─── */
#sidebar-toggle {
  display: none;
}

/* ─── SIDEBAR INNER STYLES ─── */
.sidebar-logo {
  display: block;
  text-decoration: none;
  margin-bottom: 1.6rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}
.sidebar-logo-en {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: .72rem;
  color: var(--muted);
  letter-spacing: .18em;
  text-transform: uppercase;
  display: block;
  margin-bottom: .3rem;
}
.sidebar-logo-zh {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: .05em;
}

.sidebar-section-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: .68rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.4rem 0 .6rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--line);
}

.sidebar-era-group { margin-bottom: .4rem; }
.sidebar-era-label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  padding: .35rem .5rem;
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: default;
}
.sidebar-era-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
}

.sidebar-section { margin-bottom: .3rem; }
.sidebar-section-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  font-family: 'Noto Serif SC', serif;
  letter-spacing: .06em;
  padding: .38rem .5rem;
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: .5rem;
  text-align: left;
  transition: background .2s;
}
.sidebar-section-btn:hover { background: var(--surface2); }
.sidebar-chevron {
  margin-left: auto;
  font-size: 1rem;
  line-height: 1;
  transition: transform .2s;
  color: var(--muted);
}
.sidebar-section.open .sidebar-chevron { transform: rotate(90deg); }
.sidebar-section-body { padding-left: .8rem; }
.sidebar-subgroup { margin-bottom: .5rem; }
.sidebar-subgroup-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .3rem .4rem .2rem;
  opacity: .75;
}

.sidebar-section-body a,
.sidebar-links a {
  display: block;
  text-decoration: none;
  font-size: .8rem;
  color: var(--muted);
  padding: .28rem .4rem;
  border-radius: 2px;
  transition: color .2s, background .2s;
  border-left: 2px solid transparent;
  line-height: 1.5;
}
.sidebar-section-body a:hover,
.sidebar-links a:hover { color: var(--text); background: var(--surface2); }
.sidebar-section-body a.active,
.sidebar-links a.active {
  color: var(--gold);
  border-left-color: var(--gold-dim);
  background: var(--surface2);
}

.sidebar-links { padding-left: 1.4rem; }
.sidebar-special { margin-top: 1.6rem; }
.sidebar-home-link {
  display: block;
  text-decoration: none;
  font-size: .82rem;
  color: var(--muted);
  padding: .3rem .4rem;
  border-radius: 2px;
  transition: color .2s, background .2s;
  margin-bottom: .6rem;
}
.sidebar-home-link:hover { color: var(--text); background: var(--surface2); }
.sidebar-special a {
  display: block;
  text-decoration: none;
  font-size: .8rem;
  color: var(--muted);
  padding: .28rem .4rem;
  border-radius: 2px;
  transition: color .2s, background .2s;
}
.sidebar-special a:hover { color: var(--text); background: var(--surface2); }

/* ─── PAGE HEADER ─── */
.page-header {
  width: 100%;
  max-width: var(--content-max);
  padding: 3.5rem 2rem 2.5rem;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 2rem;
  width: 40px; height: 2px;
  background: var(--gold-dim);
}

.page-era-badge {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: .75rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.page-era-badge::before {
  content: '';
  display: inline-block;
  width: 1.5rem; height: 1px;
  background: currentColor;
}

.page-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 600;
  letter-spacing: .04em;
  line-height: 1.25;
  margin-bottom: 1rem;
}

.page-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.obs-btn {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: .78rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: .08em;
  padding: .3rem .8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: all .2s;
}
.obs-btn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
}

/* ─── ARTICLE BODY ─── */
.article-body {
  width: 100%;
  max-width: var(--content-max);
  padding: 2.5rem 2rem 5rem;
}

.article-body h2 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: .04em;
  margin: 2.5rem 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
  color: var(--gold);
}

.article-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 .8rem;
  color: var(--text);
}

.article-body h4 {
  font-size: .95rem;
  font-weight: 600;
  margin: 1.5rem 0 .6rem;
  color: var(--text);
  letter-spacing: .04em;
}

.article-body h5 {
  font-size: .88rem;
  font-weight: 600;
  margin: 1.2rem 0 .5rem;
  color: var(--muted);
  letter-spacing: .06em;
}

.article-body h6 {
  font-size: .82rem;
  font-weight: 600;
  margin: 1rem 0 .4rem;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.article-body p {
  margin-bottom: 1rem;
  line-height: 1.9;
}

.article-body ul, .article-body ol {
  margin: .8rem 0 1rem 1.5rem;
}

.article-body li {
  margin-bottom: .4rem;
  line-height: 1.8;
}

.article-body ul li { list-style: none; position: relative; }
.article-body ul li::before {
  content: '·';
  position: absolute;
  left: -1rem;
  color: var(--muted);
}

.article-body ol li { list-style: decimal; }

.article-body strong { font-weight: 600; color: var(--gold); }
.article-body em { font-style: italic; }

/* ─── BLOCKQUOTE ─── */
.article-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.4rem;
  border-left: 3px solid var(--gold-dim);
  background: var(--surface);
  border-radius: 0 2px 2px 0;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.9;
}

.article-body blockquote p { margin-bottom: .4rem; color: inherit; }
.article-body blockquote p:last-child { margin-bottom: 0; }

/* ─── TABLE ─── */
.article-body .table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.article-body th {
  background: var(--surface2);
  padding: .6rem .9rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .08em;
  color: var(--muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.article-body td {
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.7;
}

.article-body tr:last-child td { border-bottom: none; }

/* ─── WIKI LINKS ─── */
.wiki-link {
  color: var(--gold-dim);
  text-decoration: none;
  border-bottom: 1px dashed var(--gold-dim);
  transition: color .2s, border-color .2s;
}
.wiki-link:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.wiki-link-missing {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dashed var(--muted);
  cursor: default;
}

/* ─── COLLAPSIBLE SECTIONS (Obsidian collapsed:: true) ─── */
.collapsible-block {
  margin: .8rem 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.collapsible-trigger {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  cursor: pointer;
  background: var(--surface);
  transition: background .2s;
  font-size: .9rem;
  user-select: none;
}

.collapsible-trigger:hover { background: var(--surface2); }

.collapsible-trigger::before {
  content: '▶';
  font-size: .65rem;
  color: var(--muted);
  transition: transform .25s;
  flex-shrink: 0;
}

.collapsible-block.open .collapsible-trigger::before {
  transform: rotate(90deg);
}

.collapsible-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}

.collapsible-block.open .collapsible-content {
  grid-template-rows: 1fr;
}

.collapsible-inner {
  overflow: hidden;
  padding: 0 1rem;
}

.collapsible-block.open .collapsible-inner {
  padding: .8rem 1rem 1rem;
}

/* ─── 串记 SPECIAL SECTION ─── */
.chuanji-block {
  margin: 2rem 0;
  padding: 1.2rem 1.5rem;
  background: linear-gradient(135deg, rgba(74,111,160,.12), rgba(224,82,82,.08));
  border: 1px solid rgba(74,111,160,.35);
  border-radius: 3px;
  position: relative;
}

.chuanji-block::before {
  content: '串记';
  position: absolute;
  top: -1px; right: 1rem;
  background: var(--gold-dim);
  color: var(--bg);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .15em;
  padding: .15rem .5rem;
  border-radius: 0 0 2px 2px;
}

.chuanji-block p, .chuanji-block li { color: var(--text); }

/* ─── SHARED PANEL BASE（backlinks / video 共用）─── */
.content-panel {
  max-width: 820px;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}

/* ─── BACKLINKS ─── */
.backlinks-section {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 0 4rem;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.backlinks-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.backlinks-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  list-style: none;
  margin: 0; padding: 0;
}

.backlinks-list li::before { display: none; }

.backlinks-list a {
  text-decoration: none;
  font-size: .82rem;
  color: var(--muted);
  padding: .3rem .8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: all .2s;
}
.backlinks-list a:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
}

/* ─── FOOTER ─── */
.page-footer {
  text-align: center;
  padding: 2.5rem 2rem;
  font-size: .72rem;
  color: var(--muted);
  letter-spacing: .1em;
  border-top: 1px solid var(--line);
  margin-left: 0;
  position: relative;
}

.page-footer::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(to right,
    #002395 0%, #002395 33.3%,
    #ffffff 33.3%, #ffffff 66.6%,
    #ED2939 66.6%, #ED2939 100%
  );
}

/* ─── AUTHOR PORTRAITS ─── */
.author-portrait {
  float: right;
  width: 120px;
  height: 150px;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--line);
  margin: 0 0 1rem 1.5rem;
  filter: grayscale(20%) sepia(10%);
  transition: filter 0.3s;
}
.author-portrait:hover { filter: grayscale(0%) sepia(0%); }
.author-portrait-caption {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  display: block;
  margin-top: 0.3rem;
}
.portrait-wrap {
  float: right;
  margin: 0 0 1rem 1.5rem;
  text-align: center;
}
.portrait-source {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-style: normal;
  font-size: 0.6rem;
  letter-spacing: .04em;
  color: var(--muted);
  opacity: 0.5;
  margin-top: 0.15rem;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }

/* ─── ANIMATIONS ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

.fade-up {
  opacity: 0;
  animation: fadeUp .7s ease forwards;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1100px) {
  /* 屏幕较小时，notes 面板默认收起 */
  :root { --notes-w: 360px; }
}

@media (max-width: 860px) {
  /* 平板/移动端：sidebar 改为浮层 overlay */
  #gl-workspace {
    display: block;  /* 恢复 block，移动端不需要三栏 */
  }

  #sidebar {
    position: fixed;
    top: var(--titlebar-h); left: 0; bottom: 0;
    width: 260px;
    transform: translateX(-260px);
    height: auto;
    transition: transform .3s cubic-bezier(.16,1,.3,1);
    opacity: 1;
    pointer-events: auto;
    z-index: 9000;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #sidebar.collapsed {
    width: 260px;
    opacity: 1;
    pointer-events: auto;
    border-right-color: var(--line);
    transform: translateX(-260px);
  }

  #gl-note-panel {
    position: fixed;
    top: var(--titlebar-h); right: 0; bottom: 0;
    width: 92vw !important;
    height: auto;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.16,1,.3,1);
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  #gl-note-panel.panel-open-mobile {
    transform: translateX(0);
  }
  #gl-note-panel.notes-collapsed {
    transform: translateX(100%);
    width: 92vw !important;
  }

  .main-content {
    padding-top: 0;  /* workspace 已处理 */
  }

  /* 移动端显示 hamburger，隐藏 focus 按钮 */
  #sidebar-focus-btn { display: none !important; }
  .titlebar-page-tab { display: none; }
  #sidebar-toggle { display: flex !important; }

  /* 右区收到最小 */
  .titlebar-right { width: auto !important; }

  .page-header { padding: 3rem 1.5rem 2rem; }
  .page-header::after { left: 1.5rem; }
  .article-body { padding: 2rem 1.5rem 4rem; }
  .backlinks-section { margin: 0 0 3rem; padding: 1.2rem 1.5rem; }

  #theme-toggle { right: .8rem; top: 1rem; }
}

@media (max-width: 500px) {
  .page-title { font-size: 1.6rem; }
  .article-body { padding: 1.5rem 1rem 3rem; }
  .backlinks-section { padding: 1rem; }
}

/* ─── BILIBILI 视频区 ─── */
.video-section {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 0 2rem;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.video-section-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.video-section-title::before {
  content: '';
  display: inline-block;
  width: 1rem; height: 1px;
  background: currentColor;
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.video-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.video-embed-wrap {
  flex-shrink: 0;
  width: 280px;
  aspect-ratio: 16/9;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.video-embed-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* 占位状态（还没放视频链接时） */
.video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .4rem;
  color: var(--muted);
  font-size: .75rem;
  letter-spacing: .1em;
}

.video-placeholder::before {
  content: '▷';
  font-size: 1.8rem;
  opacity: .3;
}

.video-meta {
  flex: 1;
}

.video-meta h4 {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .4rem;
  line-height: 1.4;
}

.video-meta p {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: .6rem;
}

.video-meta a {
  font-size: .75rem;
  color: var(--gold-dim);
  text-decoration: none;
  border-bottom: 1px dashed var(--gold-dim);
  transition: all .2s;
}
.video-meta a:hover { color: var(--gold); border-color: var(--gold); }

@media (max-width: 860px) {
  .video-section { margin: 0 0 2rem; padding: 1.2rem 1.5rem; }
  .video-item { flex-direction: column; }
  .video-embed-wrap { width: 100%; }
}
@media (max-width: 500px) {
  .video-section { padding: 1rem; }
}


/* ═══════════════════════════════════════════════
   互动功能样式：思维导图 + 名词解释闪卡
   ═══════════════════════════════════════════════ */

/* ── 导图触发按钮 ── */
.mm-trigger-btn {
  margin-left: .6rem;
}

/* ── 思维导图模态框 ── */
#mm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 20000;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}
#mm-modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%; max-width: 960px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#mm-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1.2rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
#mm-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--muted);
  font-size: .9rem;
  letter-spacing: .1em;
}
#mm-close {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-size: .85rem; padding: .3rem .6rem;
  border-radius: 3px;
  transition: color .2s, background .2s;
}
#mm-close:hover { color: var(--text); background: var(--surface2); }
#mm-canvas {
  overflow: auto; padding: 1.5rem;
  flex: 1;
}

/* ── SVG 思维导图元素 ── */
.mm-line {
  stroke: var(--line);
  fill: none;
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}
.mm-line-branch { stroke: var(--gold-dim); opacity: .7; }
.mm-line-leaf   { stroke: var(--muted); opacity: .5; }

.mm-node rect {
  transition: opacity .15s;
}
.mm-root rect {
  fill: var(--gold-dim); opacity: .85;
}
.mm-branch rect {
  fill: var(--surface2);
  stroke: var(--line); stroke-width: 1;
}
.mm-leaf rect {
  fill: var(--surface);
  stroke: var(--line); stroke-width: 1;
}
.mm-node:hover rect { opacity: .8; }

.mm-node text {
  font-family: 'Noto Serif SC', serif;
  font-size: 12px;
  fill: var(--text);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.mm-root text { fill: #fff; font-weight: 600; font-size: 11px; }
.mm-branch text { font-size: 12px; }
.mm-leaf text { font-size: 11px; fill: var(--muted); }

[data-theme="light"] .mm-root rect { fill: var(--gold-dim); }
[data-theme="light"] .mm-node text { fill: var(--text); }
[data-theme="light"] .mm-root text { fill: #fff; }

/* ── 名词解释闪卡 ── */
.fc-deck {
  margin: 1.4rem 0 2rem;
}
.fc-progress {
  display: flex; align-items: center; gap: 1rem;
  font-size: .78rem; color: var(--muted);
  margin-bottom: .8rem;
  flex-wrap: wrap;
}
.fc-count { font-weight: 600; color: var(--text); }
.fc-score b { color: #5ba87a; }

.fc-card-wrap {
  perspective: 1000px;
  height: 180px;
  margin-bottom: .8rem;
  cursor: pointer;
}
.fc-card {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4,0,.2,1);
}
.fc-card.fc-flipped { transform: rotateY(180deg); }

.fc-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface2);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1.2rem 2rem;
  text-align: center;
  transition: background .25s, border-color .25s;
}
.fc-face:hover { background: var(--surface); }
.fc-back {
  transform: rotateY(180deg);
  background: var(--surface);
}

.fc-label {
  font-size: .7rem; letter-spacing: .12em;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: .5rem;
  font-family: 'Cormorant Garamond', serif;
}
.fc-term {
  font-size: 1.35rem; font-weight: 600;
  color: var(--gold);
  font-family: 'Noto Serif SC', serif;
}
.fc-def {
  font-size: .88rem; line-height: 1.7;
  color: var(--text);
}

.fc-btns {
  display: flex; gap: .6rem; justify-content: center;
}
.fc-btn {
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: 'Noto Serif SC', serif;
  font-size: .82rem;
  padding: .45rem 1.1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.fc-btn:hover { background: var(--surface); }
.fc-know {
  background: rgba(91,168,122,.15);
  border-color: rgba(91,168,122,.4);
  color: #5ba87a;
}
.fc-know:hover { background: rgba(91,168,122,.25); }

@media (max-width: 600px) {
  .fc-card-wrap { height: 200px; }
  .fc-term { font-size: 1.1rem; }
  .fc-def  { font-size: .82rem; }
  .fc-btn  { font-size: .76rem; padding: .4rem .7rem; }
}
