/* Ember 备忘录 · 白底黑字紧密排版（手机优先，固定居中不左右晃） */
* { box-sizing: border-box; }
:root { --reader-size: 19px; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overflow-x: hidden; overflow-x: clip; }
html[data-theme="white"] {
  --bg: #ffffff; --ink: #111111; --muted: #6b7280; --line: #e5e7eb; --card: #f5f5f5;
  --strong: #1d4ed8; --link: #1d4ed8; --accent: #2563eb;
  --side-bg: #f9fafb; --side-ink: #111111; --side-muted: #6b7280; --side-hover: #f3f4f6; --side-border: #e5e7eb;
}
html[data-theme="night"] {
  --bg: #17181a; --ink: #e5e7eb; --muted: #9ca3af; --line: #2c2c2e; --card: #222326;
  --strong: #93c5fd; --link: #93c5fd; --accent: #60a5fa;
  --side-bg: #1f2023; --side-ink: #e5e7eb; --side-muted: #9ca3af; --side-hover: #2c2d31; --side-border: #2c2c2e;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: #dbeafe; color: #111111; }
html[data-theme="night"] ::selection { background: #374151; color: #fff; }

/* 顶部圆按钮：避开灵动岛与状态栏（手机上移到底部，见媒体查询） */
#menuBtn, #readerBtn {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 40;
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--ink); cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
#menuBtn { left: 12px; font-size: 20px; }
#readerBtn { right: 12px; font-size: 17px; font-weight: 700; font-family: Georgia, "Songti SC", serif; }

/* 阅读设置面板 */
#readerPanel {
  display: none; position: fixed; z-index: 45;
  top: calc(env(safe-area-inset-top, 0px) + 64px); right: 12px; width: 248px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
#readerPanel.open { display: block; }
.rp-row { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.rp-label { font-size: 14px; color: var(--muted); width: 36px; flex: none; }
.rp-row button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 8px 12px; font-size: 14px; cursor: pointer;
}
#fontSizeLabel { min-width: 26px; text-align: center; font-size: 15px; }
.theme-group { display: flex; gap: 6px; }
.theme-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.rp-hint { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* 左侧目录：浅色书库 */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px; z-index: 30;
  background: var(--side-bg); color: var(--side-ink); overflow-y: auto; overflow-x: hidden;
  transition: transform .25s ease;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}
.side-head { font-size: 22px; font-weight: 700; color: var(--side-ink); padding: 8px 4px 12px; }
.side-sub { font-size: 13px; font-weight: 400; color: var(--side-muted); margin-top: 4px; }
#search {
  width: 100%; padding: 10px 12px; border: 1px solid var(--side-border); border-radius: 10px;
  background: var(--bg); color: var(--ink); font-size: 15px; outline: none; margin-bottom: 14px;
}
#search::placeholder { color: var(--side-muted); }
.nav-sec { font-size: 13px; letter-spacing: 1px; color: var(--side-muted); margin: 18px 4px 8px; }
.nav-sec.sec-morning { color: #1d4ed8; }
.nav-sec.sec-neuro { color: #047857; }
html[data-theme="night"] .nav-sec.sec-morning { color: #60a5fa; }
html[data-theme="night"] .nav-sec.sec-neuro { color: #34d399; }
.nav-sec[class*="sec-"]::before { content: "●"; font-size: 10px; margin-right: 6px; }
.nav-item {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: none; color: var(--side-ink);
  padding: 9px 12px; border-radius: 10px; margin-bottom: 2px;
}
.nav-item:hover { background: var(--side-hover); }
.nav-item.active[data-sec="morning"] { background: #2563eb; color: #fff; }
.nav-item.active[data-sec="neuro"] { background: #059669; color: #fff; }
.nav-item .d { font-size: 12px; color: var(--side-muted); display: block; margin-bottom: 2px; }
.nav-item.active .d { color: rgba(255,255,255,.85); }
.nav-item .t { font-size: 15px; line-height: 1.45; }
.side-foot { font-size: 12px; color: var(--side-muted); padding: 20px 4px 4px; line-height: 1.7; }
#scrim { display: none; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.45); }
#content { margin-left: 300px; transition: margin-left .25s ease; overflow-x: clip; }
body.sidebar-collapsed #content { margin-left: 0; }
body.sidebar-collapsed #sidebar { transform: translateX(-100%); }

/* 正文：白底黑字、收紧行距、固定居中 */
#article {
  max-width: 700px; margin: 0 auto; padding: 24px 22px 80px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "Songti TC", Georgia, "Times New Roman", serif;
  overflow-wrap: break-word; touch-action: pan-y;
}
#article h1 { font-size: calc(var(--reader-size) + 8px); line-height: 1.4; letter-spacing: .01em; margin: 8px 0 8px; }
#article h2 { font-size: calc(var(--reader-size) + 2px); line-height: 1.5; margin: 1.2em 0 .5em; }
#article h3 { font-size: var(--reader-size); line-height: 1.5; margin: 1em 0 .4em; }
#article p {
  font-size: var(--reader-size); line-height: 1.7; letter-spacing: .01em;
  text-align: justify; text-justify: inter-ideograph; hyphens: auto;
  overflow-wrap: break-word; margin: 0 0 .7em;
}
#article li { font-size: calc(var(--reader-size) - 1px); line-height: 1.7; margin-bottom: 6px; }
#article ul, #article ol { padding-left: 24px; }
#article strong { color: var(--strong); }
#article a { color: var(--link); }
#article hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
#article img { max-width: 100%; height: auto; border-radius: 8px; }

/* 正文生词：加粗 + 蓝色点线下划线，点按弹出英文注释 */
#article button.vocab {
  font: inherit; color: var(--strong); font-weight: 700;
  background: none; border: none; border-bottom: 1.5px dotted var(--strong);
  padding: 0 1px; margin: 0; cursor: pointer;
}

/* 晨读词汇表：不用表格形式，每词一张灰色卡片 */
#article.morning-article table { display: block; width: 100%; border-collapse: separate; border-spacing: 0; margin: 16px 0; }
#article.morning-article thead { display: none; }
#article.morning-article tbody { display: block; }
#article.morning-article tr {
  display: block; background: var(--card); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 12px;
}
#article.morning-article td { display: block; border: none; padding: 0; overflow-wrap: break-word; }
#article.morning-article td:nth-child(1) { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
#article.morning-article td:nth-child(2) {
  font-size: 14px; color: var(--muted); margin-bottom: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
#article.morning-article td:nth-child(3) { font-size: 16px; margin-bottom: 6px; }
#article.morning-article td:nth-child(4) { font-size: 15px; font-style: italic; color: var(--muted); line-height: 1.6; }

.meta {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; color: var(--muted); line-height: 1.8;
  border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px;
}
.meta a { color: var(--link); }
.kicker {
  display: inline-block; font-size: 13px; font-weight: 700; color: var(--accent);
  background: var(--card); border-radius: 999px; padding: 4px 12px; margin-bottom: 8px;
}
.kicker.morning { background: #eff6ff; color: #1d4ed8; }
.kicker.neuro { background: #ecfdf5; color: #047857; }
html[data-theme="night"] .kicker.morning { background: #1e3a8a; color: #bfdbfe; }
html[data-theme="night"] .kicker.neuro { background: #064e3b; color: #a7f3d0; }
.why {
  background: var(--card); border-left: 4px solid #059669; border-radius: 0 10px 10px 0;
  padding: 12px 14px; font-size: calc(var(--reader-size) - 2px); line-height: 1.7;
  color: var(--ink); margin: 0 0 16px;
}
.srcbtn {
  display: inline-block; margin-top: 8px; padding: 11px 20px; border-radius: 999px;
  background: #059669; color: #fff !important; text-decoration: none; font-size: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.stats { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 16px 0; font-size: 15px; }
.stats td { border: 1px solid var(--line); padding: 7px 10px; overflow-wrap: break-word; }
.stats td:first-child { color: var(--muted); width: 40%; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.pager button {
  flex: 1; padding: 14px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 15px; cursor: pointer;
}
.pager button:disabled { opacity: .4; cursor: default; }
.loading { color: var(--muted); font-size: 16px; }

/* 底部阅读进度条：位于 Home 条之上，颜色跟当前板块走 */
#progress {
  position: fixed; left: 0; bottom: env(safe-area-inset-bottom, 0px);
  height: 3px; width: 0; background: #2563eb; z-index: 60;
}

/* 英文注释小窗：底部弹出的圆角卡片 */
#glossScrim {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.35);
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
}
#glossScrim.open { opacity: 1; visibility: visible; }
#glossSheet {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); z-index: 71;
  width: min(520px, calc(100vw - 32px));
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 20px; padding: 20px 22px 22px;
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
  font-family: "Songti SC", "STSong", Georgia, "Times New Roman", serif;
  opacity: 0; visibility: hidden; transform: translate(-50%, 16px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
#glossSheet.open { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
#glossClose {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
  border: none; border-radius: 50%; background: var(--card); color: var(--ink);
  font-size: 16px; cursor: pointer;
}
#glossWord { font-size: 26px; font-weight: 700; padding-right: 36px; }
#glossMeta {
  font-size: 14px; color: var(--muted); margin-top: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
#glossDef { font-size: 18px; line-height: 1.6; margin-top: 12px; }
#glossEx { font-size: 15px; font-style: italic; color: var(--muted); line-height: 1.6; margin-top: 10px; }

@media (max-width: 900px) {
  #content { margin-left: 0; }
  #sidebar { transform: translateX(-100%); width: min(320px, 86vw); }
  body.sidebar-open #sidebar { transform: translateX(0); }
  body.sidebar-open #scrim { display: block; }
  body.sidebar-collapsed #sidebar { transform: translateX(-100%); }
  /* 手机全屏：顶部只留避开灵动岛的距离，按钮移到底部 */
  #menuBtn, #readerBtn { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
  #readerPanel { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 72px); }
  #article { padding: calc(env(safe-area-inset-top, 0px) + 12px) 20px calc(80px + env(safe-area-inset-bottom, 0px)); }
}

/* 晨读新页头：来源 + 标题链接 + 选题 + 音频（2026-10-27 改版） */
.article-title { color: #2563eb; text-decoration: none; }
.article-title:hover { text-decoration: underline; }
.topic { margin: 10px 0 4px; color: var(--muted); font-size: 15px; }
.audio-player { margin: 14px 0 6px; }
.audio-player audio { width: 100%; }
/* 神外卡片要点 + PDF 按钮（2026-10-27） */
.takeaways { margin: 14px 0; padding: 12px 14px; background: #ecfdf5; border-left: 3px solid #059669; color: #111; }
.takeaways-title { font-weight: 700; color: #059669; margin-bottom: 6px; }
.takeaways ul { margin: 0; padding-left: 20px; }
.takeaways li { margin: 4px 0; }

/* Frontiers 借鉴（2026-10-27）：标题上方多一点呼吸感；按钮分主次 */
#article h2 { margin: 1.6em 0 .5em; }
.srcbtn.secondary { background: transparent; color: #059669 !important; border: 1.5px solid #059669; }

/* Frontiers 字体与桌面右侧栏（2026-10-27，li 定：字体跟 Frontiers 的无衬线） */
body, #article, #glossSheet {
  font-family: "Lato", "Helvetica Neue", -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
#article { box-sizing: border-box; }
#rail { display: none; }
@media (min-width: 1280px) {
  #content { display: flex; justify-content: center; gap: 32px; }
  #article { margin: 0; flex: 0 1 700px; }
  #rail { display: flex; flex: 0 0 240px; flex-direction: column; gap: 12px; align-self: flex-start; position: sticky; top: 96px; }
}
.rail-card { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.rail-title { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
#railToc { max-height: 55vh; overflow-y: auto; }
#railToc a { display: block; font-size: 14px; line-height: 1.5; color: var(--ink); text-decoration: none; padding: 4px 0 4px 10px; border-left: 3px solid transparent; }
#railToc a.lvl3 { padding-left: 24px; font-size: 13px; color: var(--muted); }
#railToc a.active { border-left-color: var(--rail-accent, #2563eb); color: var(--rail-accent, #2563eb); font-weight: 700; }
.rail-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.rail-tools button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 14px; cursor: pointer; }
.rail-tools button:hover { border-color: var(--rail-accent, #2563eb); }
