/* ============================================================
   《纽约客》精读 · 移动端 / 平板 阅读器
   主题：浅色（默认）/ 深色；字号、行距、字体、学习模式可调
   ============================================================ */

:root {
  --bg:        #F6F4EF;
  --bg-elev:   #FFFFFF;
  --bg-sunken: #EFEBE3;
  --ink:       #191919;
  --ink-2:     #4A4A4A;
  --ink-3:     #8A8580;
  --line:      #E6E1D7;
  --accent:    #B4342A;
  --accent-2:  #8A6A2F;
  --accent-soft:#FBEDEA;
  --star:      #D9A20B;

  --fs: 16.5px;        /* 正文基准字号，可调 */
  --lh: 1.85;          /* 行距，可调 */
  --font-read: "Georgia", "Times New Roman", "Songti SC", "SimSun", "Noto Serif SC", serif;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px -16px rgba(0,0,0,.18);
  --tabbar-h: 58px;
}

[data-theme="dark"] {
  --bg:        #121212;
  --bg-elev:   #1C1C1C;
  --bg-sunken: #171717;
  --ink:       #EDEAE4;
  --ink-2:     #B9B4AC;
  --ink-3:     #7E7970;
  --line:      #2E2C29;
  --accent:    #E4705E;
  --accent-2:  #D3A44C;
  --accent-soft:#2B1E1C;
  --star:      #E8B62B;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.8);
}

[data-font="sans"] { --font-read: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .25s, color .25s;
}

/* ---------- 布局骨架 ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 6px;
  height: 54px; padding: 0 6px 0 4px;
  padding-top: env(safe-area-inset-top);
  height: calc(54px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar.hide-back #btnBack { visibility: hidden; }
.btn-back { visibility: hidden; }
.topbar-title {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 4px;
}
.icon-btn {
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: transparent; color: var(--ink-2);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--bg-sunken); }
.progress-line {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0;
  background: var(--accent); transition: width .12s linear;
}

main { flex: 1; padding: 14px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); }
.wrap { max-width: 720px; margin: 0 auto; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); font-size: 11px; font-family: inherit;
}
.tabbar button .ic { font-size: 17px; line-height: 1; }
.tabbar button.active { color: var(--accent); }
.tabbar button .badge {
  position: absolute; transform: translate(14px, -12px);
  background: var(--accent); color: #fff; font-size: 9px; line-height: 1;
  padding: 2px 5px; border-radius: 9px; font-weight: 700;
}

/* ---------- 通用组件 ---------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.chip {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 3px 7px;
}
.chip.muted { color: var(--ink-3); background: var(--bg-sunken); }
.section-h {
  display: flex; align-items: baseline; gap: 8px;
  margin: 22px 2px 10px; font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.section-h .n { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.muted { color: var(--ink-3); }
.hr { height: 1px; background: var(--line); border: 0; margin: 18px 0; }

/* ---------- 期号封面卡 ---------- */
.issue {
  position: relative; overflow: hidden;
  padding: 22px 20px 20px; border-radius: 18px;
  background:
    radial-gradient(120% 90% at 88% 8%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 62%),
    linear-gradient(160deg, #23211E 0%, #33302B 55%, #423C33 100%);
  color: #F5F1E8;
  box-shadow: var(--shadow);
}
[data-theme="dark"] .issue { background:
    radial-gradient(120% 90% at 88% 8%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 62%),
    linear-gradient(160deg, #1A1A1A 0%, #232323 60%, #2C2A26 100%); }
.issue .masthead { font-family: Georgia, serif; font-size: 27px; font-weight: 700; letter-spacing: .5px; }
.issue .masthead .zh { display:block; font-family: inherit; font-size: 13px; font-weight: 500; letter-spacing: .3em; opacity: .72; margin-top: 4px; }
.issue .line { margin-top: 12px; font-size: 12.5px; opacity: .82; line-height: 1.7; }
.issue .stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.issue .stat {
  font-size: 11.5px; padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(4px);
}
.issue .cover-note { margin-top: 14px; font-size: 12px; opacity: .7; line-height: 1.65; border-top: 1px solid rgba(255,255,255,.16); padding-top: 12px; }
.issue .cover-note b { font-weight: 600; opacity: .95; }

/* ---------- 文章卡片 ---------- */
.art-card {
  display: block; width: 100%; text-align: left; font-family: inherit;
  padding: 14px 15px; margin-bottom: 10px; cursor: pointer;
  background: var(--bg-elev); color: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .2s;
}
.art-card:active { transform: scale(.985); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.art-card.done { opacity: .62; }
.art-card .row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.art-card .num { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-left: auto; }
.art-card h3 { margin: 0 0 3px; font-size: 16.5px; font-weight: 700; line-height: 1.35; }
.art-card h3 .en { display: block; font-family: Georgia, serif; font-size: 15px; font-weight: 400; color: var(--ink-2); margin-top: 2px; }
.art-card .meta { font-size: 11.5px; color: var(--ink-3); margin-bottom: 7px; }
.art-card .tldr { font-size: 13px; color: var(--ink-2); line-height: 1.62;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.art-card .tags { display: flex; gap: 6px; margin-top: 9px; }
.tag { font-size: 10.5px; color: var(--ink-3); background: var(--bg-sunken); border-radius: 6px; padding: 3px 7px; }
.tag.on { color: var(--star); }

/* ---------- 文章页 ---------- */
.article-head { padding: 4px 2px 0; }
.article-head .catline { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.article-head h1 { margin: 0; font-family: Georgia, serif; font-size: 27px; line-height: 1.22; letter-spacing: -.2px; }
.article-head .zh-title { margin: 8px 0 0; font-size: 17px; font-weight: 600; color: var(--ink-2); }
.article-head .byline { margin-top: 12px; font-size: 12.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px 12px; }
.tldr-box {
  margin-top: 16px; padding: 13px 15px; border-radius: var(--radius-sm);
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  font-size: 13.5px; line-height: 1.7; color: var(--ink);
}
.tldr-box .lbl { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--accent); margin-bottom: 5px; text-transform: uppercase; }

.segmented {
  position: sticky; top: calc(54px + env(safe-area-inset-top)); z-index: 30;
  display: flex; gap: 4px; margin: 16px 0 4px; padding: 4px;
  background: var(--bg-sunken); border-radius: 11px;
}
.segmented button {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 8px 2px; border-radius: 8px;
  white-space: nowrap;
}
.segmented button.active { background: var(--bg-elev); color: var(--accent); box-shadow: var(--shadow); }

.reading { font-family: var(--font-read); font-size: var(--fs); line-height: var(--lh); color: var(--ink); }
.reading p { margin: 0 0 1.05em; }
.reading p:first-letter { }
.reading ol, .reading ul { padding-left: 1.2em; }
.reading .lead { font-size: 1.02em; }

/* 导语段落序号 */
.guide-item { position: relative; padding-left: 22px; margin-bottom: .95em; }
.guide-item::before {
  content: ""; position: absolute; left: 4px; top: .72em;
  width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 55%, transparent);
}

/* ---------- 词汇卡 ---------- */
.vocab-card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 13px; margin-bottom: 9px; box-shadow: var(--shadow);
}
.vocab-card .head { display: flex; align-items: flex-start; gap: 10px; }
.vocab-card .w { font-family: Georgia, serif; font-size: 18px; font-weight: 700; line-height: 1.25; }
.vocab-card .ipa { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-family: Georgia, serif; }
.vocab-card .pos { font-size: 11px; color: var(--accent-2); font-style: italic; margin-left: 6px; }
.vocab-card .zh { margin-top: 7px; font-size: 14px; font-weight: 600; }
.vocab-card .note {
  margin-top: 8px; font-size: 13px; color: var(--ink-2); line-height: 1.68;
  border-top: 1px dashed var(--line); padding-top: 8px;
  display: none;
}
.vocab-card.open .note { display: block; }
.vocab-card .hint { font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.vocab-card.open .hint { display: none; }
.star-btn {
  margin-left: auto; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-3);
  font-size: 15px; cursor: pointer; line-height: 1;
}
.star-btn.on { color: var(--star); border-color: color-mix(in srgb, var(--star) 45%, var(--line)); background: color-mix(in srgb, var(--star) 12%, transparent); }

/* ---------- 精读句段 ---------- */
.ex-block {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 15px; margin-bottom: 11px; box-shadow: var(--shadow);
}
.ex-block .en { font-family: Georgia, serif; font-size: 1.06em; line-height: 1.66; color: var(--ink); }
.ex-block .en b { background: color-mix(in srgb, var(--star) 26%, transparent); font-weight: 600; border-radius: 3px; padding: 0 2px; }
.ex-toggle {
  margin-top: 12px; width: 100%; border: 1px dashed var(--line); background: transparent;
  color: var(--accent); font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 8px; border-radius: 8px; cursor: pointer;
}
.ex-body { display: none; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.ex-block.open .ex-body { display: block; }
.ex-block.open .ex-toggle { display: none; }
.ex-body .zh { font-size: 14.5px; line-height: 1.78; font-weight: 500; }
.ex-body .note { margin-top: 10px; font-size: 13px; color: var(--ink-2); line-height: 1.72; }
.ex-body .note b { color: var(--accent-2); }

/* ---------- 原文（原文页签） ---------- */
.orig-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 16px 2px 12px;
}
.orig-head .ol { font-size: 10.5px; font-weight: 800; letter-spacing: .18em; color: var(--accent); }
.orig-head .om { font-size: 11.5px; color: var(--ink-3); }

.reading.original { color: var(--ink); }
.reading.original p { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.reading.original p:first-of-type::first-letter {
  float: left; font-family: Georgia, serif; font-size: 3.05em; line-height: .84;
  font-weight: 700; color: var(--accent); margin: .04em .09em 0 0;
}
.reading.original p:first-of-type::first-line { }

/* 原文里已注释的难词 */
.reading.original mark.vw {
  background: transparent; color: inherit; padding: 0; border-radius: 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 58%, transparent);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.reading.original mark.vw:active { background: var(--accent-soft); }
.orig-foot .demo-vw { border-bottom: 1px dashed color-mix(in srgb, var(--accent) 58%, transparent); }

.orig-foot {
  margin: 24px 2px 0; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-3); line-height: 1.75;
}

.orig-empty {
  margin-top: 18px; padding: 26px 20px; text-align: center;
  background: var(--bg-elev); border: 1px dashed var(--line); border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 14px; line-height: 1.85;
}
.orig-empty .oe-ic { font-size: 22px; color: var(--accent); margin-bottom: 8px; }

.orig-loading { margin: 26px 0; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.orig-loading .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: middle;
  animation: origPulse 1s ease-in-out infinite;
}
@keyframes origPulse { 0%, 100% { opacity: .22 } 50% { opacity: 1 } }

/* 诗歌版式 */
.verse {
  margin: 0 0 22px; padding: 16px 16px 14px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.verse-head { margin-bottom: 12px; }
.verse-head .vt { display: block; font-family: Georgia, serif; font-size: 17px; font-weight: 700; }
.verse-head .vz { display: block; font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.verse-head .va { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
.verse-body { font-family: var(--font-read); font-size: calc(var(--fs) - .5px); line-height: 1.78; }
.verse-body .vline { display: block; padding-left: 1.15em; text-indent: -1.15em; }

/* 原文难词气泡 */
.vpop {
  position: fixed; left: 0; top: 0; z-index: 70; width: 320px; max-width: calc(100vw - 24px);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 13px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .2);
  padding: 13px 14px; opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
.vpop.open { opacity: 1; visibility: visible; transform: translateY(0); }
.vpop .vp-head { display: flex; align-items: flex-start; gap: 10px; }
.vpop .vp-w { font-family: Georgia, serif; font-size: 17px; font-weight: 700; line-height: 1.25; }
.vpop .vp-pos { font-size: 11px; color: var(--accent-2); font-style: italic; margin-left: 6px; }
.vpop .vp-ipa { font-size: 11.5px; color: var(--ink-3); font-family: Georgia, serif; margin-top: 2px; }
.vpop .vp-zh { margin-top: 8px; font-size: 14px; font-weight: 600; }
.vpop .vp-note {
  margin-top: 8px; font-size: 12.5px; color: var(--ink-2); line-height: 1.68;
  border-top: 1px dashed var(--line); padding-top: 8px;
}
.vpop .star-btn { width: 30px; height: 30px; font-size: 14px; }

/* ---------- 搜索面板 ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column;
}
.sheet.open { transform: translateY(0); }
.sheet-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.sheet-bar input {
  flex: 1; border: 0; outline: 0; background: var(--bg-sunken); color: var(--ink);
  font-family: inherit; font-size: 15px; padding: 11px 14px; border-radius: 11px;
}
.sheet-body { flex: 1; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }

/* ---------- 设置 ---------- */
.set-group { margin-bottom: 18px; }
.set-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 15px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px;
}
.set-row .lab { flex: 1; min-width: 0; font-size: 14px; }
.set-row .lab .sub { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.seg-sm { display: inline-flex; background: var(--bg-sunken); border-radius: 9px; padding: 3px; }
.seg-sm button {
  border: 0; background: transparent; color: var(--ink-2); font-family: inherit;
  font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 7px; cursor: pointer;
}
.seg-sm button.active { background: var(--bg-elev); color: var(--accent); box-shadow: var(--shadow); }
.btn {
  width: 100%; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink);
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 13px; border-radius: var(--radius-sm); cursor: pointer;
}
.btn.danger { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: 12px; opacity: .5; }
.empty p { font-size: 13.5px; line-height: 1.7; margin: 6px 0 0; }

.foot-note { margin: 26px 4px 8px; font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }

/* ============================================================
   平板 / 桌面：≥ 900px 双栏（左目录 + 右正文）
   ============================================================ */
.desktop-only { display: none; }

@media (min-width: 900px) {
  body { overflow: hidden; }
  .tabbar { display: none; }
  main { padding: 22px 28px 60px; }
  .app { flex-direction: row; height: 100dvh; overflow: hidden; min-height: 0; }
  .sidebar {
    display: block; flex: 0 0 296px; width: 296px;
    border-right: 1px solid var(--line); height: 100dvh; position: sticky; top: 0;
    overflow-y: auto; padding: 18px 14px 40px; background: var(--bg-sunken);
  }
  .sidebar .masthead-sm { font-family: Georgia, serif; font-size: 19px; font-weight: 700; padding: 0 6px 4px; }
  .sidebar .masthead-sm .zh { display: block; font-size: 11px; letter-spacing: .28em; color: var(--ink-3); font-family: inherit; margin-top: 3px; }
  .sidebar .tools { display: flex; gap: 8px; padding: 12px 6px 14px; }
  .sidebar .tools button { flex: 1; }
  .nav-item {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; cursor: pointer;
    border: 0; background: transparent; color: var(--ink-2); font-family: inherit;
    font-size: 13px; padding: 9px 10px; border-radius: 9px; line-height: 1.4;
  }
  .nav-item .idx { font-size: 10px; color: var(--ink-3); width: 16px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
  .nav-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-item:hover { background: var(--bg); }
  .nav-item.active { background: var(--bg-elev); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
  .nav-group { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; color: var(--ink-3); padding: 14px 10px 6px; text-transform: uppercase; }

  .content-col { flex: 1; min-width: 0; overflow-y: auto; height: 100dvh; }
  .content-col .topbar { padding-left: 20px; }
  .wrap { max-width: 700px; }
  .wrap.wide { max-width: 860px; }
  .reading { font-size: calc(var(--fs) * .96); }
  .article-head h1 { font-size: 32px; }
  .segmented { top: 54px; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .two-col .art-card { margin-bottom: 0; height: 100%; }
}

@media (min-width: 1180px) {
  .sidebar { flex-basis: 320px; width: 320px; }
  .wrap { max-width: 720px; }
}
