:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #fbfbfc;
  --border: #e8e9ee;
  --border-strong: #dcdde4;
  --text: #1f2128;
  --text-soft: #3b3f48;
  --muted: #8a909c;
  --accent: #5e6ad2;
  --accent-hover: #4f5bc9;
  --accent-soft: #eceefb;
  --gloss: #b45309;
  --gloss-bg: #fdf0d5;
  --green: #15a05a;
  --green-bg: #e3f6ec;
  --warn: #d97706;
  --danger: #dc2626;
  --danger-bg: #fdeaea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 30, .04), 0 1px 3px rgba(20, 22, 30, .04);
  --shadow-md: 0 6px 24px rgba(20, 22, 30, .08);
  --shadow-lg: 0 12px 40px rgba(20, 22, 30, .16);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}
::selection { background: #d8dcfa; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 11px 22px; background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 2px; }
.tab {
  border: none; background: transparent; padding: 6px 13px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--muted); font-size: 14px;
  font-weight: 500; transition: background .15s, color .15s;
}
.tab:hover { background: var(--panel-2); color: var(--text-soft); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.review-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 13px; color: var(--text-soft); }
.review-toggle input { accent-color: var(--accent); }
.badge { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 500; }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-warn { background: #fdf0d5; color: var(--warn); }

/* ---------- 视图 / 工具栏 ---------- */
.view { max-width: 800px; margin: 0 auto; padding: 26px 22px 80px; }
.hidden { display: none !important; }
.toolbar-stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--panel);
  padding: 5px 13px; border-radius: 999px; cursor: pointer; font-size: 13px; color: var(--muted);
  font-weight: 500; transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text-soft); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text-soft);
  padding: 6px 13px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; font-weight: 500;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.btn:hover { border-color: var(--border-strong); background: var(--panel-2); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: #f3d0d0; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { padding: 3px 10px; font-size: 12.5px; }
.link-btn { border: none; background: transparent; color: var(--accent); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--accent-soft); }
.back-btn { margin-bottom: 18px; }
select.btn { appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a909c' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
input.btn { font-family: inherit; }

/* ---------- 剪藏卡片 ---------- */
.clip-list { display: flex; flex-direction: column; gap: 10px; }
.clip-card {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform .14s, box-shadow .14s, border-color .14s;
}
.clip-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.clip-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.clip-head img { width: 30px; height: 30px; border-radius: 50%; }
.clip-author { font-weight: 600; font-size: 14px; }
.clip-handle, .clip-time { color: var(--muted); font-size: 13px; }
.clip-source { margin-left: auto; font-size: 12px; color: var(--muted); }
.cat-tag { color: var(--accent); font-weight: 600; }
.clip-text { font-size: 15px; white-space: pre-wrap; word-break: break-word; color: var(--text-soft); }
.clip-meta { margin-top: 9px; display: flex; gap: 10px; align-items: center; }
.clip-badge { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.clip-badge.annotated { background: var(--green-bg); color: var(--green); border-color: transparent; }
.clip-badge.marked { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.thumb-row { display: flex; gap: 6px; margin-top: 10px; }
.thumb-row img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); }
.thumb-video { position: relative; }
.thumb-video::after { content: "▶"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.card-del {
  position: absolute; bottom: 10px; right: 12px; border: none; background: transparent;
  color: var(--muted); font-size: 14px; cursor: pointer; opacity: 0; transition: opacity .12s;
  padding: 3px 6px; border-radius: 6px;
}
.clip-card:hover .card-del { opacity: .8; }
.card-del:hover { background: var(--danger-bg); color: var(--danger); opacity: 1; }

/* ---------- 阅读页 ---------- */
.reading-pane { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px 30px; box-shadow: var(--shadow-sm); }
.reading-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.reading-head img { width: 44px; height: 44px; border-radius: 50%; }
.reading-actions { display: flex; gap: 8px; margin: 20px 0; flex-wrap: wrap; }
.reading-text { font-size: 18px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }
.reading-text a { color: var(--accent); }
.reading-text code, .ctree-text code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; padding: .5px 5px; font-size: .9em; }
.md-quote { display: block; border-left: 3px solid var(--border-strong); padding-left: 12px; color: var(--muted); margin: 4px 0; }

.reading-media { margin-top: 16px; display: grid; grid-template-columns: 1fr; gap: 8px; }
.reading-media.cols2 { grid-template-columns: 1fr 1fr; }
.media-item { position: relative; border-radius: var(--radius); overflow: hidden; cursor: pointer; background: #0c0c10; }
.reading-media:not(.cols2) .media-item img,
.reading-media:not(.cols2) .media-item video {
  display: block; margin: 0 auto; width: auto; height: auto; max-width: 100%; max-height: 520px;
}
.reading-media.cols2 .media-item { height: 220px; }
.reading-media.cols2 .media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-noposter { aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; color: #fff; }
.media-item .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.media-item .play span { width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.media-item .zoom-hint { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 9px; pointer-events: none; }
.media-open-original { font-size: 13px; color: var(--accent); display: inline-block; padding: 14px; }

/* 生词高亮 */
.gloss { background: var(--gloss-bg); border-radius: 3px; padding: 0 2px; cursor: help; }
.gloss.recur { box-shadow: inset 0 -7px 0 -4px var(--accent-soft); }
.marked-word { background: #eceefb; border-radius: 3px; padding: 0 2px; }

/* 译文 */
.translation { margin-top: 20px; padding: 16px 18px; border-left: 3px solid var(--accent); background: linear-gradient(180deg, var(--accent-soft), #f5f6fe); border-radius: 0 var(--radius) var(--radius) 0; }
.translation-body { font-size: 16px; color: var(--text); white-space: pre-wrap; }
.trans-tools { display: flex; justify-content: flex-end; gap: 4px; margin-top: 8px; }
.trans-edit { width: 100%; min-height: 90px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px; font-family: inherit; font-size: 15px; resize: vertical; }
.trans-edit-actions { display: flex; gap: 8px; margin-top: 8px; }

/* 圈选区一行 */
.marked-list { margin-top: 16px; padding: 10px 14px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.marked-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; font-size: 13px; }
.marked-chip .x { cursor: pointer; font-weight: 700; opacity: .55; }
.marked-chip .x:hover { opacity: 1; }
.marked-chip .tag { font-style: normal; font-size: 10.5px; background: var(--warn); color: #fff; padding: 0 5px; border-radius: 7px; }

/* 生词清单 */
.vocab-inline { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 18px; }
.vocab-inline h4 { margin: 0 0 12px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.vi-item { padding: 9px 0; border-bottom: 1px solid var(--border); }
.vi-word { font-weight: 600; }
.vi-phon { color: var(--muted); font-style: italic; margin: 0 6px; }
.vi-pos { color: var(--gloss); font-size: 13px; margin-right: 6px; }
.vi-note { color: var(--muted); font-size: 13px; margin-top: 2px; }
.reading-time { text-align: right; color: var(--muted); font-size: 12px; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 10px; }

/* 引用卡片 */
.quote-card { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; background: var(--panel-2); }
.quote-head { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.quote-text { font-size: 15px; white-space: pre-wrap; word-break: break-word; color: var(--text-soft); }
.quote-card .reading-media { margin-top: 10px; }

/* 评论上下文 / 评论树 */
.comment-context { margin-bottom: 14px; padding: 9px 13px; background: var(--accent-soft); border-radius: var(--radius-sm); font-size: 13px; color: var(--accent); }
.comment-context a { color: var(--accent); font-weight: 600; }
.ctree { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.ctree h4 { margin: 0 0 14px; font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 10px; }
.ctnode { margin: 2px 0; }
.ctitem { padding: 7px 0; }
.ctchildren { margin-left: 7px; padding-left: 15px; border-left: 2px solid var(--border); }
.ctree-head { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.ct-time { color: var(--muted); font-weight: 400; }
.ctree-actions { margin-left: auto; display: flex; gap: 6px; }
.mini-btn { border: 1px solid var(--border); background: var(--panel); color: var(--muted); border-radius: 6px; padding: 1px 8px; font-size: 12px; cursor: pointer; font-weight: 500; }
.mini-btn:hover { border-color: var(--border-strong); color: var(--text-soft); background: var(--panel-2); }
.mini-btn.del { color: var(--muted); font-weight: 400; }
.mini-btn.del:hover { color: var(--danger); border-color: #f3d0d0; background: var(--danger-bg); }
.ctree-text { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; margin-top: 3px; color: var(--text-soft); }
.ctree-text a { color: var(--accent); }
.ctree-trans { font-size: 13.5px; color: var(--accent); margin-top: 5px; white-space: pre-wrap; }
.mini-badge { font-size: 11px; padding: 1px 8px; border-radius: 8px; background: var(--panel-2); color: var(--muted); font-weight: 400; border: 1px solid var(--border); }
.mini-badge.ok { background: var(--green-bg); color: var(--green); border-color: transparent; }

/* 复习模式：隐藏中文/释义 */
body.review-mode .translation-body,
body.review-mode .ctree-trans,
body.review-mode .vi-mean,
body.review-mode .vi-note,
body.review-mode .vi-phon { filter: blur(5px); transition: filter .15s; }
body.review-mode .translation-body:hover,
body.review-mode .ctree-trans:hover,
body.review-mode .vi-mean:hover,
body.review-mode .vi-note:hover,
body.review-mode .vi-phon:hover { filter: none; }
body.review-mode .gloss { background: transparent; }

/* ---------- 生词库 ---------- */
.vocab-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.vcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); transition: box-shadow .14s; }
.vcard:hover { box-shadow: var(--shadow-md); }
.vcard-word { font-weight: 700; font-size: 16px; }
.vcard-phon { color: var(--muted); font-style: italic; font-size: 13px; }
.vcard-mean { margin: 7px 0; color: var(--text-soft); }
.vcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; }
.vcard-foot select { font-size: 12px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); }
.vcard-occur { color: var(--accent); cursor: pointer; }
.vcard-occur:hover { text-decoration: underline; }
.vcard-occur-panel { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.occur-row { font-size: 12.5px; color: var(--text-soft); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.occur-row:hover { background: var(--panel-2); }
.occur-row.muted { color: var(--muted); cursor: default; }
.vocab-list.vocab-hidden .vcard-mean { filter: blur(5px); transition: filter .15s; }
.vocab-list.vocab-hidden .vcard-mean:hover { filter: none; }

/* ---------- 浮层 / 灯箱 / 弹窗 ---------- */
.tooltip { position: fixed; z-index: 100; max-width: 280px; background: #1d1f27; color: #fff; padding: 9px 13px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; box-shadow: var(--shadow-lg); pointer-events: none; }
.tooltip .tt-word { font-weight: 700; }
.tooltip .tt-phon { color: #aeb3c2; font-style: italic; }
.mark-btn { position: fixed; z-index: 120; padding: 5px 12px; font-size: 13px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; box-shadow: var(--shadow-md); }
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(10, 10, 14, .9); display: flex; align-items: center; justify-content: center; cursor: zoom-out; backdrop-filter: blur(4px); }
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border: none; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; font-size: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lb-nav:hover { background: rgba(255,255,255,.3); }
#lbPrev { left: 18px; } #lbNext { right: 18px; }

/* flair 版块标签 */
.flair-pill { display: inline-block; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; margin-bottom: 14px; }

/* 多图轮播 */
.carousel { position: relative; border-radius: var(--radius); overflow: hidden; background: #0c0c10; margin-top: 16px; }
.car-track { display: flex; transition: transform .25s ease; }
.car-slide { min-width: 100%; }
.carousel .media-item { background: transparent; border-radius: 0; }
.carousel .media-item img, .carousel .media-item video { width: 100%; height: 460px; object-fit: contain; display: block; }
.car-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: none; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; }
.car-nav:hover { background: rgba(0,0,0,.7); }
.car-nav.prev { left: 8px; } .car-nav.next { right: 8px; }
.car-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; }
.car-dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.5); cursor: pointer; }
.car-dots span.on { background: #fff; }

.modal { position: fixed; inset: 0; z-index: 280; background: rgba(10, 10, 14, .4); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal-card { background: var(--panel); border-radius: 16px; padding: 24px; width: min(560px, 92vw); box-shadow: var(--shadow-lg); }
.modal-card h3 { margin: 0 0 16px; font-size: 17px; }
.modal-input { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; font-family: inherit; font-size: 15px; margin-bottom: 12px; }
textarea.modal-input { min-height: 160px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 手动帖：大标题 / 副标题 / 备注 */
.manual-head { margin-bottom: 18px; }
.manual-title { font-size: 26px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
.manual-subtitle { font-size: 16px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.manual-note { margin-top: 18px; padding: 11px 14px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text-soft); }

/* 顶栏图标按钮 */
.icon-btn { border: none; background: transparent; cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 8px; line-height: 1; }
.icon-btn:hover { background: var(--panel-2); }

/* 阅读页底部：时间 + 删除 */
.reading-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 10px; }
.reading-foot .reading-time { border: none; margin: 0; padding: 0; }
.icon-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 8px; }
.icon-del:hover { background: var(--danger-bg); color: var(--danger); }

/* 设置面板 */
.set-check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.set-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-soft); }
.set-grid input { padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; }
.set-hint { font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }

.empty { text-align: center; color: var(--muted); padding: 70px 20px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #1d1f27; color: #fff; padding: 10px 18px; border-radius: var(--radius-sm); z-index: 200; opacity: 0; transition: opacity .2s; box-shadow: var(--shadow-lg); font-size: 14px; }
.toast.show { opacity: 1; }

/* ---------- 手机端适配 ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { flex-wrap: wrap; gap: 10px 14px; padding: 9px 14px; }
  .brand { font-size: 15px; }
  .topbar-right { gap: 10px; }
  .review-toggle span { display: none; }          /* 手机只留勾选框 */
  .view { padding: 16px 12px 70px; }
  /* 筛选横向滑动，不换行挤一堆 */
  .filters { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { flex-wrap: wrap; }
  .reading-pane { padding: 18px 15px; border-radius: 12px; }
  .reading-text { font-size: 17px; }
  .manual-title { font-size: 22px; }
  .vocab-list { grid-template-columns: 1fr; }
  .reading-media:not(.cols2) .media-item img,
  .reading-media:not(.cols2) .media-item video { max-height: 70vh; }
  .carousel .media-item img, .carousel .media-item video { height: 56vw; max-height: 70vh; }
  .reading-media.cols2 { grid-template-columns: 1fr; }   /* 引用/评论多图手机上单列 */
  .lb-nav { width: 40px; height: 40px; font-size: 22px; }
  #lbPrev { left: 6px; } #lbNext { right: 6px; }
}
