/* ============ 基础变量与主题 ============ */
:root {
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --primary-contrast: #fff;
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --text: #1f2430;
  --text-soft: #5b6172;
  --border: #e5e7f0;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --warn: #d97706;
  --marked: #f59e0b;
  --marked-bg: #fef3c7;
  --shadow: 0 4px 18px rgba(31, 36, 48, .08);
  --radius: 14px;
  --passage-size: 20px;
  --phonetic-size: 12px;
}
html[data-theme="dark"] {
  --primary: #818cf8;
  --primary-soft: #2a2f55;
  --primary-contrast: #14162b;
  --bg: #12141d;
  --surface: #1b1e2b;
  --surface-2: #222637;
  --text: #e7e9f2;
  --text-soft: #9aa1b5;
  --border: #2e3346;
  --ok: #4ade80;
  --ok-bg: #14301f;
  --bad: #f87171;
  --bad-bg: #3a1d1d;
  --warn: #fbbf24;
  --marked: #fbbf24;
  --marked-bg: #3d2f10;
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --primary: #818cf8;
    --primary-soft: #2a2f55;
    --primary-contrast: #14162b;
    --bg: #12141d;
    --surface: #1b1e2b;
    --surface-2: #222637;
    --text: #e7e9f2;
    --text-soft: #9aa1b5;
    --border: #2e3346;
    --ok: #4ade80;
    --ok-bg: #14301f;
    --bad: #f87171;
    --bad-bg: #3a1d1d;
    --warn: #fbbf24;
    --marked: #fbbf24;
    --marked-bg: #3d2f10;
    --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  }
}
html[data-font="s"] { --passage-size: 17px; }
html[data-font="m"] { --passage-size: 20px; }
html[data-font="l"] { --passage-size: 24px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
button { font-family: inherit; }

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

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-logo { font-size: 20px; }
.topbar-right { margin-left: auto; display: flex; gap: 6px; }
.admin-shortcut { color: var(--primary); }
/* 电脑端顶部导航：默认隐藏，宽屏显示（替代底部导航） */
.topnav { display: none; }

.content {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 110px;
}
@media (min-width: 760px) {
  .content { padding: 28px 28px 40px; }
}

.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .row.gap { flex-wrap: wrap; }
.page-head.compact h1 { font-size: 20px; }
/* 操作页（打字/标注/留空/默写/助记）：标题独占整行宽度，功能键另起一行，不影响标题排版 */
.page-head.stack { flex-direction: column; align-items: stretch; }
.page-head.stack .page-head-main { width: 100%; flex: 1 1 100%; }
.page-head.stack .page-actions { width: 100%; flex: 1 1 100%; justify-content: flex-start; }
.page-head.stack .page-actions .back-library { margin-right: auto; }
.page-sub { color: var(--text-soft); font-size: 13.5px; margin-top: 4px; }
.grow { flex: 1; min-width: 0; }
.top-user { font-size: 13px; color: var(--text-soft); margin-right: 8px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-tabs { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.lang-tab { padding: 8px 16px; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-soft); }
.lang-tab.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(79,70,229,.3); }
#wordSearch { min-width: 220px !important; flex: 2 !important; }
.daily-quote { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, transparent), transparent); }
.daily-quote .quote-text { font-size: 14px; font-weight: 600; line-height: 1.6; }
.daily-quote .quote-trans { font-size: 12.5px; color: var(--text-soft); margin-top: 6px; line-height: 1.5; }
.pin-btn { background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; font-size: 12px; padding: 3px 8px; border-radius: 6px; opacity: 0.8; }
.pin-btn.on { opacity: 1; border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.article-card.pinned { border-color: var(--primary); border-width: 2px; }
/* 下拉跳转定位时短暂高亮 */
.article-card.flash { animation: cardFlash 1.2s ease-out; }
@keyframes cardFlash {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 70%, transparent); background: color-mix(in srgb, var(--primary) 18%, transparent); }
  60% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; background: transparent; }
}

/* 客户发布版首屏注册区；管理员入口由服务端身份动态显示 */
.client-welcome {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1.1fr);
  gap: 20px; align-items: center; margin: 0 0 18px; padding: 20px;
  border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border));
  border-radius: var(--radius); background: linear-gradient(135deg, var(--primary-soft), var(--surface));
  box-shadow: var(--shadow);
}
body[data-app-mode="admin"] .brand-name::after {
  content: " · 开发管理端"; color: var(--primary); font-size: 12px; font-weight: 600;
}
body[data-app-mode="client"] #cloudSetup { display: none !important; }
.client-welcome-copy h2 { margin: 5px 0 6px; font-size: 21px; }
.client-welcome-copy p { color: var(--text-soft); font-size: 13.5px; line-height: 1.7; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.client-auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.client-auth-actions .input, .client-auth-actions .hint { grid-column: span 2; }
.client-auth-actions .btn { min-height: 42px; }
@media (max-width: 680px) {
  .client-welcome { grid-template-columns: 1fr; padding: 16px; }
  .client-auth-actions { grid-template-columns: 1fr; }
  .client-auth-actions .input, .client-auth-actions .hint { grid-column: span 1; }
  .admin-shortcut { display: none; }
}

/* ============ 通用控件 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.seg.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text);
  font-size: 18px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.back-btn { font-size: 20px; font-weight: 700; }

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.row.wrap { flex-wrap: wrap; }
.margin-top { margin-top: 12px; }

.input, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}
.input:focus, .textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.textarea { resize: vertical; line-height: 1.6; }
.textarea.small { font-size: 14px; }
.field-label { font-size: 13.5px; color: var(--text-soft); font-weight: 600; display: block; margin: 10px 0 6px; }
.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.field-row:first-child { margin-top: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.hint { color: var(--text-soft); font-size: 13px; line-height: 1.7; }
.file-btn { cursor: pointer; position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 6px; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-btn::after { content: '📄'; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel-soft { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.device-self-service { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.device-list { display: grid; gap: 8px; margin-top: 10px; }
.device-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.device-item span { display: flex; flex-direction: column; min-width: 0; }
.device-item small { color: var(--text-soft); overflow-wrap: anywhere; }
.admin-create h4 { margin: 0; font-size: 14px; }
.panel h3 { font-size: 15.5px; margin-bottom: 6px; }
.panel .hint + .hint { margin-top: 6px; }
.danger-panel { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }

/* ============ 文章库左右分栏 ============ */
.library-layout { display: block; }
@media (min-width: 900px) {
  .library-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 18px;
    align-items: start;
  }
  .library-side { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
  .library-side .panel { margin-bottom: 10px; }
}
@media (max-width: 899px) {
  .library-side { margin-top: 16px; }
  .import-fab { display: flex !important; }
}
.import-fab {
  display: none;
  position: fixed; bottom: 80px; right: 16px; z-index: 50;
  width: 52px; height: 52px; border-radius: 50%;
  background: #6c5ce7; color: #fff; font-size: 24px;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(108,92,231,.4);
  border: none; cursor: pointer;
}

/* ============ 文章卡片 ============ */
.article-list { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) { .article-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .library-main .article-list { grid-template-columns: 1fr; } }
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .1s, border-color .15s;
}
.article-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.article-card h3 { font-size: 16.5px; word-break: break-word; }
.card-preview {
  color: var(--text-soft); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-soft); }
.tag {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px;
}
.tag.marked { background: var(--marked-bg); border-color: transparent; color: var(--warn); }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.card-actions .btn { padding: 7px 12px; font-size: 13px; }
.empty {
  text-align: center; color: var(--text-soft);
  padding: 50px 20px; border: 1.5px dashed var(--border); border-radius: var(--radius);
}
.empty .big { font-size: 38px; display: block; margin-bottom: 8px; }

/* ============ 文章正文（阅读/打字/留空共用） ============ */
.passage {
  font-size: var(--passage-size);
  line-height: 2.1;
  word-break: break-word;
  white-space: pre-wrap;
}
.reader-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.reader-body .word { border-radius: 4px; cursor: pointer; }
.reader-body .word:hover { background: var(--primary-soft); }
.reader-body.show-phonetic .word {
  display: inline-block; text-align: center; vertical-align: bottom;
  margin: 0 1px; position: relative;
}
.reader-body.show-phonetic .word .ph {
  display: block; font-size: var(--phonetic-size); color: var(--primary); line-height: 1.1;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700;
  white-space: nowrap; margin-top: 1px; opacity: .95;
}
.reader-body.show-phonetic .word .ph.missing,
.preview-body.show-phonetic .word .ph.missing,
.cloze-body.show-phonetic .ph.missing { color: var(--text-soft); opacity: .55; }
.reader-body .word.marked {
  background: var(--marked-bg);
  color: var(--warn);
  border-bottom: 2px solid var(--marked);
  font-weight: 600;
}
.preview-body .word { border-radius: 4px; cursor: pointer; }
.preview-body .word:hover { background: var(--primary-soft); }
.preview-body .word.marked {
  background: var(--marked-bg);
  color: var(--warn);
  border-bottom: 2px solid var(--marked);
  font-weight: 600;
}

/* 中英对照段落（英文段 + 中文译文段） */
.reader-body .en-p {
  margin: 0 0 4px;
  font-size: var(--passage-size);
  line-height: 2.1;
  word-break: break-word;
}
.reader-body .en-p + .zh-p { margin-bottom: 20px; }
.reader-body .zh-p {
  margin: 0 0 20px;
  padding: 10px 14px;
  font-size: calc(var(--passage-size) - 4px);
  line-height: 1.9;
  color: var(--text-soft);
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.reader-body .zh-p[hidden] { display: none; }

/* ============ 打字练习 ============ */
.stats-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-bottom: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
}
.stat-label { display: block; font-size: 11.5px; color: var(--text-soft); }
.stat-value { font-size: 15px; font-weight: 700; }
.stat-value b { color: var(--primary); }

.type-wrap { position: relative; }
.type-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  cursor: text;
  max-height: 62vh; overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
.type-text .c { color: var(--text-soft); border-radius: 3px; position: relative; }
.type-text .c.ok { color: var(--text); }
.type-text .c.bad { color: var(--bad); background: var(--bad-bg); }
.type-text .c.nl.bad::after { background: var(--bad); }
.type-text .c.cur {
  background: var(--primary-soft);
  box-shadow: inset 0 -2.5px 0 var(--primary);
  color: var(--text);
  animation: blink-cur 1.1s ease-in-out infinite;
}
@keyframes blink-cur { 0%, 100% { box-shadow: inset 0 -2.5px 0 var(--primary); } 50% { box-shadow: inset 0 -2.5px 0 transparent; } }
.type-text .word.marked { background: var(--marked-bg); }
.type-text.annotate { cursor: default; }
.type-text.annotate .word { cursor: pointer; }
.type-text.annotate .word:hover { background: var(--primary-soft); }
.type-text.show-phonetic .word { display: inline-block; text-align: center; vertical-align: bottom; }
.type-text.show-phonetic .word .ph,
.preview-body.show-phonetic .word .ph,
.cloze-body.show-phonetic .ph {
  display: block; color: var(--primary); font-size: var(--phonetic-size); line-height: 1.1;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700;
  white-space: nowrap;
}
html:not(.phonetic-clear) .reader-body.show-phonetic .ph,
html:not(.phonetic-clear) .type-text.show-phonetic .ph,
html:not(.phonetic-clear) .preview-body.show-phonetic .ph,
html:not(.phonetic-clear) .cloze-body.show-phonetic .ph {
  color: var(--text-soft); font-weight: 500; opacity: .72;
}
.cloze-word { display: inline-block; text-align: center; vertical-align: bottom; }
/* 留空练习：非显示音标态隐藏音标（支持练习中免重渲染切换） */
.cloze-body:not(.show-phonetic) .ph { display: none; }
/* 操作页整篇译文容器（打字 / 留空） */
.bilingual-trans {
  margin-top: 10px; padding: 10px 14px;
  border: 1px dashed var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.bilingual-trans[hidden] { display: none; }
.bilingual-trans .trans-tag { font-size: 12px; color: var(--text-soft); opacity: .8; margin-bottom: 4px; }
.bilingual-trans .zh-p { color: var(--text-soft); font-size: 14px; line-height: 1.75; margin: 6px 0; }
.bilingual-trans .trans-empty { color: var(--text-soft); font-size: 13px; opacity: .8; }
.type-input {
  position: absolute; left: 0; top: 0;
  width: 1px; height: 1px; opacity: 0;
  border: none; padding: 0; background: transparent;
  font-size: 16px; /* 避免 iOS 缩放 */
}

/* 完成弹层 */
.result-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 12, 22, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.result-mask[hidden] { display: none; }
.result-card {
  background: var(--surface); border-radius: 18px;
  padding: 26px 22px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}
.result-card h2 { margin-bottom: 18px; }
.result-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; margin-bottom: 20px; }
.result-grid > div {
  background: var(--surface-2); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column;
}
.result-grid b { font-size: 26px; color: var(--primary); }
.result-grid span { font-size: 12.5px; color: var(--text-soft); }

/* ============ 留空练习 ============ */
.cloze-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.cloze-input {
  font: inherit;
  border: none;
  border-bottom: 2.5px solid var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 6px 6px 0 0;
  padding: 0 6px;
  margin: 0 2px;
  text-align: center;
  font-weight: 700;
  min-width: 48px;
  line-height: 1.6;
}
.cloze-input:focus { outline: none; background: color-mix(in srgb, var(--primary) 16%, transparent); }
.cloze-input.ok { border-bottom-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.cloze-input.bad { border-bottom-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.cloze-body.checked .cloze-input { pointer-events: none; }
.cloze-score {
  text-align: center; font-size: 17px; font-weight: 700;
  margin-top: 14px; color: var(--primary);
}
#extraRow input[type="range"] { flex: 1; min-width: 140px; accent-color: var(--primary); }

/* ============ 单词本 ============ */
.word-list { display: flex; flex-direction: column; gap: 8px; }
.word-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.word-item .w-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.word-item .w-text { font-weight: 700; font-size: 16px; min-width: 110px; word-break: break-word; }
.word-item .w-meta {
  font-size: 12px; color: var(--text-soft);
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  padding-left: 2px; user-select: none;
}
.word-item .w-meta .dot { opacity: 0.5; }
#wordSourceFilter, #wordSortFilter { max-width: 210px; }

/* 搭配语料（单词下方小字） */
.word-item .w-collocations {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 6px; padding: 8px 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
}
.word-item .w-coll {
  font-size: 12.5px; line-height: 1.55;
  color: var(--text-soft);
  display: flex; flex-direction: column; gap: 1px;
}
.word-item .w-coll-s { color: var(--text); font-style: italic; word-break: break-word; }
.word-item .w-coll-src { font-size: 11px; opacity: 0.7; }

/* 文章库分类筛选 chips */
.category-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 6px 0 16px;
}
.category-bar .chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px; font-family: inherit;
  padding: 5px 10px; border-radius: 999px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: border-color .15s, color .15s, background .15s;
}
.category-bar .chip:hover { border-color: var(--primary); color: var(--text); }
.category-bar .chip.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.category-bar .chip-count {
  font-size: 11px; opacity: 0.75;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.category-bar .chip.active .chip-count {
  background: rgba(255,255,255,0.25); opacity: 1;
}

/* 文章卡片上的分类标签（可点击编辑） */
.article-card .category-tag { cursor: pointer; }
.article-card .category-tag:hover { border-color: var(--primary); color: var(--primary); }
.article-card .category-tag.ghost {
  border-style: dashed; color: var(--text-soft); opacity: 0.85;
}
.article-card .category-tag.ghost:hover { opacity: 1; }
.article-card .category-tag.static { cursor: default; opacity: 0.9; }
.article-card .category-tag.static:hover { border-color: var(--border); color: inherit; }

/* ============ 批量管理 ============ */
.batch-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 4px 0 14px; padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.batch-toolbar .batch-info {
  font-size: 13px; color: var(--text-soft); margin-right: 4px;
}
.batch-toolbar .batch-info b { color: var(--primary); font-size: 15px; }

#batchModeBtn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* 批量模式下卡片样式：可点击 + 选中高亮 */
.article-card.batch { cursor: pointer; position: relative; }
.article-card.batch:hover { border-color: var(--primary); }
.article-card.batch.selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  box-shadow: 0 0 0 1px var(--primary);
}
.article-card .batch-check {
  position: absolute; top: 10px; right: 12px;
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: var(--surface);
  transition: background .15s, border-color .15s;
  user-select: none;
}
.article-card.batch.selected .batch-check {
  background: var(--primary); border-color: var(--primary);
}
.article-card.batch.selected .batch-check::before { content: '✓'; }

/* ============ 分类选择模态框 ============ */
.cat-modal-mask {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10, 12, 22, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.cat-modal-mask[hidden] { display: none; }
.cat-modal-card {
  background: var(--surface); border-radius: 18px;
  padding: 22px 20px; width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex; flex-direction: column; gap: 6px;
}
.cat-modal-card h3 { font-size: 17px; margin-bottom: 6px; }
.cat-modal-card .field-label { margin-top: 6px; }
.cat-modal-card .hint { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.cat-modal-card select.input,
.cat-modal-card input.input { width: 100%; }

/* 试用倒计时弹窗 */
.trial-countdown {
  font-size: 22px; font-weight: 700; color: var(--primary);
  text-align: center; padding: 16px 0;
}

/* 积分兑换列表 */
.redeem-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.redeem-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.redeem-item:hover:not(.disabled) { border-color: var(--primary); background: var(--primary-soft); }
.redeem-item.disabled { opacity: .5; cursor: not-allowed; }
.redeem-item .redeem-info { display: flex; flex-direction: column; gap: 2px; }
.redeem-item .redeem-info b { font-size: 14px; }
.redeem-item .redeem-info .hint { margin-top: 0; }

/* 管理员用户管理表格 */
.admin-table-wrap { overflow: auto; max-height: 400px; border: 1px solid var(--border); border-radius: 8px; }
.admin-table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px;
}
.admin-table th, .admin-table td {
  padding: 6px 8px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.admin-table th { background: #f0f2f5; font-weight: 600; position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--primary-soft); }
.word-item .w-note {
  flex: 1; min-width: 0;
  background: transparent; border: 1px solid transparent;
  color: var(--text-soft); font-size: 14px; font-family: inherit;
  border-radius: 8px; padding: 6px 8px;
}
.word-item .w-note:focus { outline: none; border-color: var(--primary); background: var(--surface-2); color: var(--text); }
.word-item .w-del {
  border: none; background: transparent; color: var(--text-soft);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.word-item .w-del:hover { color: var(--bad); background: var(--bad-bg); }
.word-item .w-speak {
  border: none; background: transparent; color: var(--text-soft);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
  transition: background .15s, color .15s;
}
.word-item .w-speak:hover { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }

/* 单词词典信息：音标 / 词性 / 中文意思 / 助记 */
.word-item .w-phonetic {
  color: var(--text-soft); font-size: 13px; font-family: "Segoe UI", Georgia, serif;
  margin-right: auto; white-space: nowrap;
}
.word-item .w-dict {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 2px 2px 0;
}
.word-item .w-pos {
  font-style: normal; font-weight: 700; font-size: 12px;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 6px; padding: 1px 7px; white-space: nowrap;
}
.word-item .w-meaning { font-size: 15px; color: var(--text); word-break: break-word; }
.word-item .w-mnemonic,
.word-item .w-note {
  width: 100%; flex: none;
  background: transparent; border: 1px solid transparent;
  color: var(--text-soft); font-size: 13.5px; font-family: inherit;
  border-radius: 8px; padding: 6px 8px;
}
.word-item .w-mnemonic { color: #b45309; }
html[data-theme="dark"] .word-item .w-mnemonic { color: #fbbf24; }
.word-item .w-mnemonic:focus,
.word-item .w-note:focus { outline: none; border-color: var(--primary); background: var(--surface-2); color: var(--text); }

/* 文章卡片译文标记 */
.tag.zh-tag { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.tag.zh-tag.loading { opacity: 0.65; }

/* ============ 朗读工具条 ============ */
.tts-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgba(0,0,0,.12);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px;
}
.tts-bar[hidden] { display: none; }
.tts-bar .tts-info {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-soft);
}
.tts-bar .tts-mode-tag {
  background: var(--primary); color: #fff;
  padding: 2px 8px; border-radius: 999px; font-size: 11px;
}
.tts-bar .tts-progress { color: var(--primary); font-weight: 600; }
.tts-bar .tts-cur {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text); font-style: italic; opacity: 0.85;
}
.tts-bar .tts-controls {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.tts-bar .tts-btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 16px; cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.tts-bar .tts-btn:hover { border-color: var(--primary); }
.tts-bar .tts-btn.primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.tts-bar .tts-btn.primary.paused { background: var(--surface-2); color: var(--primary); }
.tts-bar .tts-field {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-soft);
}
.tts-bar .tts-field select.input {
  width: auto; min-width: 70px; padding: 4px 8px; font-size: 13px;
}
.tts-bar .tts-loop {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-soft); cursor: pointer;
  user-select: none;
}
.tts-bar .tts-loop input { margin: 0; }
.tts-bar #ttsClose {
  width: 32px; height: 32px; font-size: 18px; color: var(--text-soft);
  margin-left: auto;
}
/* 工具条打开时给底部留出空间（避免遮住单词本/文章列表底部） */
body.tts-active .content { padding-bottom: 110px; }

/* ============ 底部导航 ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-soft);
  font-size: 11px;
  padding: 7px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab span { font-size: 17px; }
.tab.active { color: var(--primary); font-weight: 700; }
@media (min-width: 760px) {
  .tabbar { display: none; }
  /* 电脑端：顶部导航替代底部导航 */
  .topnav { display: flex; align-items: center; gap: 4px; margin-left: 14px; }
  .topnav .tab {
    flex-direction: row; gap: 6px;
    font-size: 14px; font-weight: 500;
    padding: 8px 14px; border-radius: 10px;
    transition: background 0.15s, color 0.15s;
  }
  .topnav .tab:hover { background: var(--surface-2); color: var(--text); }
  .topnav .tab.active { font-weight: 700; background: color-mix(in srgb, var(--primary) 10%, transparent); }
  .content { padding-bottom: 40px; }
}

.quick-nav-row {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 16px;
}
.quick-nav-btn {
  flex-direction: row !important; gap: 6px;
  font-size: 14px !important; font-weight: 500;
  padding: 10px 18px !important; border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}
.quick-nav-btn:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.quick-nav-btn span { font-size: 16px !important; }
.quick-nav-btn.active { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); font-weight: 700; }
.quick-nav-btn.danger { color: #d33; border-color: color-mix(in srgb, #d33 40%, var(--border)); }
.quick-nav-btn.danger:hover { background: color-mix(in srgb, #d33 14%, transparent); }
.quick-nav-manage { border-style: dashed; }
.searchable-select { position: relative; flex: 1; min-width: 200px; max-width: 400px; }
.searchable-select input { width: 100%; }
.searchable-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  max-height: 280px; overflow-y: auto; margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.searchable-dropdown .sd-item {
  padding: 10px 14px; cursor: pointer; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.searchable-dropdown .sd-item:hover, .searchable-dropdown .sd-item.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.searchable-dropdown .sd-empty { padding: 12px 14px; color: var(--text-dim); font-size: 13px; }
.phonetic-size-select { width: auto; min-width: 76px; padding: 6px 8px; }
.article-note { margin-top: 16px; }
.article-note h3 { margin: 0; }
/* 笔记框：右下角可自由拉宽拉高（resize:both），自动保存 */
.article-note .textarea { margin-top: 10px; min-height: 90px; resize: both; max-width: 100%; }
.preview-tools { margin: 8px 0 6px; }
.quick-nav-editor { display: grid; gap: 8px; margin-top: 12px; }
.quick-nav-edit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2);
}
.quick-nav-edit-row label > span { display: inline-flex; flex-direction: column; gap: 1px; }
.quick-nav-edit-row small { color: var(--text-soft); font-size: 11px; font-weight: 400; }
.quick-nav-edit-actions { display: inline-flex; gap: 2px; }
.quick-nav-edit-actions .icon-btn.small { width: 30px; height: 30px; font-size: 15px; }

.footer-note { text-align: center; color: var(--text-soft); font-size: 12px; margin-top: 22px; }

/* ============ 单词备注弹层 ============ */
.popover {
  position: fixed; z-index: 70;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  padding: 14px;
  width: min(320px, calc(100vw - 32px));
}
.pop-word { font-size: 20px; font-weight: 800; color: var(--primary); margin-bottom: 8px; word-break: break-word; }

/* ============ 悬浮取词翻译卡片 ============ */
.dict-pop {
  position: fixed; z-index: 80;
  width: min(300px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0,0,0,.24);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  animation: dict-in .12s ease;
}
@keyframes dict-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.dict-pop .dp-head { display: flex; align-items: center; gap: 10px; }
.dict-pop .dp-word { font-size: 19px; font-weight: 800; color: var(--primary); word-break: break-word; }
.dict-pop .dp-phonetic {
  font-size: 13px; color: var(--text-soft);
  font-family: "Segoe UI", Georgia, serif;
}
.dict-pop .dp-icon {
  margin-left: auto; border: none; background: transparent;
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.dict-pop .dp-icon:hover { background: var(--surface-2); }
.dict-pop .dp-pos {
  font-size: 12px; font-weight: 700; color: var(--primary);
  display: flex; flex-wrap: wrap; gap: 6px;
}
.dict-pop .dp-meaning { font-size: 16px; color: var(--text); line-height: 1.5; word-break: break-word; }
/* 自主添加内容（自定义备注 / 助记联想 / 词根） */
.dict-pop .dp-user {
  margin: 6px 0; padding: 8px 10px;
  background: color-mix(in srgb, var(--warn) 10%, var(--surface-2));
  border: 1px dashed color-mix(in srgb, var(--warn) 45%, var(--border));
  border-radius: 8px; font-size: 12.5px; line-height: 1.55;
}
.dict-pop .dp-user-head { font-size: 11px; font-weight: 700; color: var(--warn); margin-bottom: 4px; letter-spacing: .03em; }
.dict-pop .dp-user-row { color: var(--text); word-break: break-word; }
.dict-pop .dp-user-row + .dp-user-row { margin-top: 3px; }
.dict-pop .dp-user-tag { font-size: 11px; font-weight: 700; color: var(--warn); margin-right: 3px; }
/* 中文补充信息：拼音 / 偏旁 / 词语 / 成语 */
.dict-pop .dp-cn {
  margin: 6px 0; padding: 8px 10px;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface-2));
  border: 1px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: 8px; font-size: 12.5px; line-height: 1.55;
}
.dict-pop .dp-cn-head { font-size: 11px; font-weight: 700; color: var(--primary); margin-bottom: 4px; letter-spacing: .03em; }
.dict-pop .dp-cn-row { color: var(--text); word-break: break-word; }
.dict-pop .dp-cn-row + .dp-cn-row { margin-top: 3px; }
.dict-pop .dp-cn-tag { font-size: 11px; font-weight: 700; color: var(--primary); margin-right: 3px; }
.dict-pop .dp-defs { display: flex; flex-direction: column; gap: 3px; }
.dict-pop .dp-def { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; }
.dict-pop .dp-def em {
  font-style: normal; color: var(--primary); font-weight: 700;
  font-size: 11px; margin-right: 2px;
}
.dict-pop .dp-loading { font-size: 12.5px; color: var(--text-soft); }
.dict-pop .dp-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.dict-pop .dp-actions .btn { padding: 6px 12px; font-size: 13px; }
.dict-pop #dpFav.done { background: var(--marked-bg); border-color: var(--marked); color: var(--warn); }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 90px;
  transform: translateX(-50%);
  background: rgba(20, 22, 34, .92); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 90;
  max-width: calc(100vw - 40px); text-align: center;
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 默写训练 ============ */
.dict-bar {
  height: 6px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; margin: 10px 0 14px;
}
.dict-bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .25s; }
.dict-prompt {
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  min-height: 56px;
  font-size: var(--passage-size);
  line-height: 2.1;
  word-break: break-word;
}
.dict-prompt .dict-line { white-space: pre-wrap; }
.dict-prompt .zh-line {
  color: var(--text);
  font-size: 1.18em;
  font-weight: 600;
  line-height: 1.9;
  letter-spacing: .5px;
  padding: 6px 2px;
}
.dict-prompt .c { color: var(--text-soft); border-radius: 3px; }
.dict-prompt .c.ok { color: var(--text); }
.dict-prompt .c.bad { color: var(--bad); background: var(--bad-bg); }
.dict-prompt .c.miss { color: var(--text-soft); border-bottom: 2px solid var(--marked); }
.dict-prompt .c.reveal { color: var(--text); }
.dict-prompt .c.cur {
  background: var(--primary-soft);
  box-shadow: inset 0 -2.5px 0 var(--primary);
  color: var(--text);
  animation: blink-cur 1.1s ease-in-out infinite;
}
.dict-prompt b { color: var(--primary); font-weight: 800; }
.dict-prompt .dots { color: var(--text-soft); letter-spacing: 1px; }
.dict-meta { display: block; color: var(--text-soft); font-size: 12.5px; line-height: 1.6; margin-bottom: 4px; }
.typed-line { color: var(--text-soft); font-size: .82em; }
.dict-input { font-size: 17px; line-height: 1.7; }
.dict-summary { margin-top: 4px; }
/* 默写：上一句/跳过此句 导航行 */
.dict-nav { padding-top: 4px; border-top: 1px dashed var(--border); }
.dict-nav #dictNavHint { font-size: 12px; opacity: .8; }

/* ============ 文章卡片：标题/预览 可点击 ============ */
.article-card h3,
.article-card .card-preview { cursor: pointer; }
.article-card h3:hover { color: var(--primary); }

/* ============ 文章预览模态框 ============ */
.preview-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 18px 18px 16px;
  width: 100%; max-width: 640px;
  max-height: calc(100vh - 60px);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex; flex-direction: column; gap: 8px;
}
.preview-card .preview-head { align-items: flex-start; gap: 12px; }
.preview-card .preview-head h3 { word-break: break-word; font-size: 17px; }
.preview-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-soft); }
.preview-body {
  overflow-y: auto; flex: 1; min-height: 80px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
  font-size: var(--passage-size); line-height: 1.9; white-space: pre-wrap; word-break: break-word;
}
.preview-body p { margin: 0 0 10px; }
.preview-body p:last-child { margin-bottom: 0; }
.preview-body.show-phonetic .word {
  display: inline-block; text-align: center; vertical-align: bottom;
  margin: 0 1px;
}
.preview-actions { gap: 8px; flex-wrap: wrap; }
@media (max-width: 480px) {
  .preview-card { padding: 14px 12px; max-height: calc(100vh - 20px); }
  .preview-body { padding: 10px 12px; font-size: 15px; }
  .preview-actions .btn { padding: 8px 10px; font-size: 12px; }
  .quick-nav-btn { padding: 8px 12px !important; font-size: 12px !important; }
  .card-actions .btn { padding: 6px 10px; font-size: 12px; }
}

/* ============ 助记训练 ============ */
.mem-progress { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-soft); }
.flashcard {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-height: 180px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  user-select: none;
  transition: transform .1s, border-color .15s;
}
.flashcard:hover { border-color: var(--primary); }
.flashcard:active { transform: scale(.99); }
.fc-face { animation: fade .18s ease; }
.fc-word { font-size: 32px; font-weight: 800; color: var(--primary); word-break: break-word; }
.fc-src { margin-top: 8px; font-size: 12.5px; color: var(--text-soft); }
/* 助记三级烙印徽章 */
.lvl-badge { display: inline-block; vertical-align: middle; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
.lvl-badge.lvl-0 { background: var(--bad-bg); color: var(--bad); }
.lvl-badge.lvl-1 { background: var(--marked-bg); color: var(--warn); }
.lvl-badge.lvl-2 { background: var(--ok-bg); color: var(--ok); }
.fc-word .lvl-badge { font-size: 13px; }
.fc-note { font-size: 20px; line-height: 1.7; word-break: break-word; }
.fc-mnemonic {
  display: block; width: min(420px, 100%); margin-top: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px;
}
.fc-mnemonic:focus { outline: 2px solid var(--primary); border-color: transparent; }
.fc-face .hint { font-size: 14px; }
.notes-list { display: grid; gap: 12px; }
.note-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.note-item h3 { font-size: 15px; word-break: break-word; }
.note-item .note-input { margin-top: 10px; }

.sc-chips, .sc-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.sc-chips { margin: 14px 0 6px; }
.sc-slots { min-height: 50px; margin-top: 8px; align-content: flex-start; }
.sc-chip, .sc-slot {
  width: 44px; height: 50px;
  border-radius: 10px;
  font-size: 20px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.sc-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.sc-chip:disabled { opacity: .2; cursor: default; }
.sc-slot {
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--primary);
}
.sc-slot.filled { border-style: solid; background: var(--primary-soft); }
.sc-slots.ok .sc-slot { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.sc-slots.bad { animation: shake .3s; }
@keyframes shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.sc-answer { font-size: 28px; font-weight: 800; color: var(--primary); padding: 4px 8px; word-break: break-word; }

/* ============================================================
 * 授权：激活门 / 面板 / 升级 / VIP / 文档 / 新手指引
 * ============================================================ */

/* ---------- 激活门（全屏锁定） ---------- */
.gate-mask {
  position: fixed; inset: 0; z-index: 200;
  background: color-mix(in srgb, var(--bg) 92%, #000 8%);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.gate-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  padding: 28px 26px calc(22px + env(safe-area-inset-bottom));
}
.gate-logo {
  width: 64px; height: 64px; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; border-radius: 18px;
  background: var(--primary-soft); color: var(--primary);
}
.gate-card h2 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.hint.center { text-align: center; }
.gate-input { letter-spacing: .5px; font-weight: 600; }
.gate-btn { width: 100%; margin-top: 14px; padding: 13px; font-size: 16px; }
.gate-msg { min-height: 22px; margin: 8px 2px 0; font-size: 13.5px; color: var(--bad); }
.gate-links { margin-top: 10px; }
.gate-contact { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.link-btn {
  border: none; background: none; color: var(--primary);
  font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 6px 10px;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- 注册引导：侧边悬浮面板（不遮挡文章库） ---------- */
.side-panel {
  position: fixed;
  top: 50%; right: 18px;
  transform: translateY(-50%);
  z-index: 150;
  width: min(288px, calc(100vw - 28px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  padding: 14px 14px calc(12px + env(safe-area-inset-bottom));
}
.side-panel .panel-close {
  position: absolute; top: 10px; right: 12px;
  border: none; background: none; font-size: 24px; line-height: 1;
  color: var(--muted, #999); cursor: pointer; padding: 4px 8px;
  border-radius: 8px;
}
.side-panel .panel-close:hover { color: var(--text); background: var(--border, rgba(0,0,0,.06)); }
@media (max-width: 640px) {
  .side-panel {
    top: auto; bottom: 0; right: 0; left: 0;
    transform: none;
    width: 100%;
    /* 从85vh改成72vh，弹窗变矮很多，适合手机注册表单 */
    max-height: 72vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
@media (max-width: 640px) {
  .side-panel {
    top: auto; bottom: 0; right: 0; left: 0;
    transform: none;
    width: 100%;
    max-height: 72vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    /* 新增：当虚拟键盘弹出自动适配 */
    height: auto;
  }
}


/* ---------- 我的授权面板 ---------- */
.lic-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-top: 14px;
}
.lic-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.lic-k { font-size: 12px; color: var(--text-soft); }
.lic-v { font-size: 15.5px; word-break: break-word; }
.lic-device code, #vipDeviceId, #licDeviceId {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; font-size: 12px;
  user-select: all; word-break: break-all;
}
@media (min-width: 640px) { .lic-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- 升级 / VIP 弹窗 ---------- */
.upsell-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.upsell-opt {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface-2);
}
.upsell-opt .btn { align-self: flex-start; }
.vip-plans { display: flex; gap: 10px; margin: 10px 0 14px; flex-wrap: wrap; }
.vip-plan {
  flex: 1 1 90px; text-align: center;
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 8px;
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 6px;
}
.vip-plan b { color: var(--primary); font-size: 16px; }
.vip-plan span { font-size: 12px; color: var(--text-soft); }

/* ---------- 文档型弹窗（使用说明 / 规则） ---------- */
.doc-modal { z-index: 120; }

/* ============================================================
 * 规则说明页
 * ============================================================ */
.rules-page {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.rule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.rule-card h3 {
  font-size: 16.5px;
  margin: 0 0 10px;
  color: var(--primary);
}
.rule-card h4 {
  font-size: 14.5px;
  margin: 14px 0 6px;
}
.rule-card ol, .rule-card ul {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1.7;
  font-size: 14px;
}
.rule-card p { margin: 8px 0; line-height: 1.7; font-size: 14px; }
.rule-warn {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  color: var(--warn);
  font-size: 13px;
}
.rule-redeem { gap: 8px; }
.rule-tier {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 10px 0;
  background: var(--surface-2);
}
.rule-tier-h {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; flex-wrap: wrap;
}
.rule-tier-h b { font-size: 15px; color: var(--primary); }
.rule-tier-h span { font-size: 13px; color: var(--text-soft); }
.rule-tier .hint { margin: 4px 0 0; font-size: 13px; }

/* ---------- 匿名体验横幅 ---------- */
.anon-banner {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border));
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.anon-banner b { color: var(--warn); font-size: 15px; }
.anon-banner .hint { margin: 6px 0 0; font-size: 12.5px; line-height: 1.6; }

/* ---------- 通用工具 ---------- */
.center-block { display: block; margin: 12px auto 0; }
.tag-anon, .tag-reg {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag-anon {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}
.tag-reg {
  color: var(--ok);
  background: var(--ok-bg);
}
.doc-card {
  width: min(720px, 94vw);
  max-height: 86vh; display: flex; flex-direction: column;
}
.doc-body { overflow-y: auto; margin-top: 10px; padding-right: 6px; }
.doc-body details {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 10px; background: var(--surface-2);
}
.doc-body summary {
  cursor: pointer; font-weight: 700; font-size: 15px; color: var(--text);
  list-style: none;
}
.doc-body summary::before { content: '▸ '; color: var(--primary); }
.doc-body details[open] summary::before { content: '▾ '; }
.doc-body ul { margin: 10px 0 2px; padding-left: 20px; }
.doc-body li { font-size: 13.5px; color: var(--text-soft); margin: 6px 0; line-height: 1.7; }
.doc-body li b { color: var(--text); }
.rules-body p { margin: 14px 0 6px; font-size: 14.5px; }
.rules-body ol { margin: 0; padding-left: 22px; }
.rules-body li { font-size: 13.5px; color: var(--text-soft); margin: 6px 0; line-height: 1.75; }
.rules-body li b { color: var(--text); }

/* ---------- 新手指引 ---------- */
.tour-mask {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 18, 32, .55);
}
.tour-spot {
  position: fixed; z-index: 1;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(15, 18, 32, .72), 0 0 0 3px var(--primary);
  transition: all .22s ease;
  pointer-events: none;
}
.tour-pop {
  position: fixed; z-index: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  padding: 16px 18px;
}
.tour-progress { font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.tour-pop h4 { font-size: 17px; margin: 0 0 6px; color: var(--primary); }
.tour-pop p { font-size: 14px; line-height: 1.7; color: var(--text); margin: 0; }
.tour-pop .btn[disabled] { opacity: .4; pointer-events: none; }
/* （注：内容由AI生成） */

/* ============================================================
 * 双语并列样式（UI 文本始终中英双语显示）
 * - 短文本（按钮/标签）：data-i18n 返回 "英文 / 中文" 纯文本，自动换行
 * - 长正文（help/rules）：data-i18n-html 返回
 *   <div class="bi-en">…</div><div class="bi-cn">…</div> 上下排列
 * ============================================================ */

/* 长正文双语并列容器 */
.bi-en, .bi-cn { display: block; }
.bi-en { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.bi-en[lang="en"], .bi-cn[lang="zh"] { line-height: 1.7; }
.bi-en:last-child, .bi-cn:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }

/* 顶部 brand name：双语显示时允许换行不溢出 */
.brand-name {
  white-space: normal;
  line-height: 1.3;
  max-width: 220px;
}
@media (min-width: 900px) {
  .brand-name { max-width: 320px; }
}

/* tabbar 底部按钮双语文字允许换行 */
.tabbar .tab span,
.lang-tabs .lang-tab {
  white-space: normal;
  line-height: 1.25;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* 通用按钮双语文字自动换行 */
.btn, .icon-btn, .lang-tab, .tab {
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

/* 长文本按钮（如操作页标题区按钮）允许更宽换行 */
.row.gap.page-actions .btn,
.row.gap .btn { min-height: 34px; }

/* 短按钮双语用 「/」 分隔时压缩空格 */
.btn.compact-bi { letter-spacing: -0.2px; }

/* ===== 手机端优化 ===== */
@media (max-width: 680px) {
  /* 底部导航：紧凑不换行 */
  .tabbar { grid-template-columns: repeat(6, 1fr); }
  .tabbar .tab { font-size: 9px; padding: 5px 2px 6px; gap: 1px; }
  .tabbar .tab span { font-size: 16px; }
  .tabbar .tab span:last-child {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%; font-size: 9px; line-height: 1.1; display: block;
  }
  /* 快捷入口按钮：小一号 */
  .quick-nav-btn { font-size: 12px !important; padding: 7px 12px !important; border-radius: 8px; }
  .quick-nav-btn span { font-size: 13px !important; }
  /* 删除按钮不要红色描边 */
  .quick-nav-btn.danger { color: inherit; border-color: var(--border); background: var(--surface-2); }
  .quick-nav-btn.danger:hover { background: color-mix(in srgb, #d33 10%, transparent); color: #d33; }
  /* 搜索框 */
  .searchable-select { min-width: 100%; max-width: 100%; }
  /* 标题 */
  .brand-name { font-size: 14px !important; }
}
/* （注：内容由AI生成） */

