/* ===== 自托管 Plus Jakarta Sans（5 字重，按需加载） ===== */
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plus-jakarta-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0102, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+0300-0304, U+0308-0309, U+0323, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/plus-jakarta-sans-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0102, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+0300-0304, U+0308-0309, U+0323, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/plus-jakarta-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0102, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+0300-0304, U+0308-0309, U+0323, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/plus-jakarta-sans-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0102, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+0300-0304, U+0308-0309, U+0323, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/plus-jakarta-sans-latin-800-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0102, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+0300-0304, U+0308-0309, U+0323, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

:root {
  color-scheme: only light;
  /* 学练岛 design tokens（现代扁平 SaaS） */
  --ink: #1d2233;            /* 深墨蓝，正文 */
  --ink-soft: #454c61;
  --muted: #5b6472;          /* 次级文字：浅底对比度 ≥4.5:1 */
  --faint: #9aa1b2;
  --line: #e7e9f1;           /* 冷调发丝描边 */
  --line-strong: #d6d9e4;
  --surface: #ffffff;        /* 卡片 */
  --surface-sunken: #f6f7fb;
  --canvas: #f3f4f9;         /* 浅灰蓝地面 */
  --accent: #5b5ff0;         /* indigo 主色，仅用于可操作/选中 */
  --accent-strong: #484bd6;
  --accent-soft: #ecebfe;
  --shell: #14182e;          /* 深色侧栏/页眉 */
  --shell-strong: #0d1020;
  --shell-soft: #ecebfe;
  --on-shell: #eef1fb;
  --on-shell-muted: #8b93b5;
  --success: #16a34a;
  --success-soft: #e3f6ea;
  --warning: #d97706;
  --warning-soft: #fcf0d8;
  --danger: #e11d48;
  --danger-soft: #fde7ec;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 46, .06);
  --shadow: 0 4px 12px -2px rgba(20, 24, 46, .08), 0 2px 6px -2px rgba(20, 24, 46, .06);
  --shadow-lg: 0 12px 28px -8px rgba(20, 24, 46, .16), 0 4px 10px -6px rgba(20, 24, 46, .10);
  --font-sans: "Plus Jakarta Sans", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-family: var(--font-sans);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 15.5px;
  line-height: 1.7;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
button { font: inherit; }

/* ===== 全局排版精修：统一高级字体节奏（标题负字距、正文舒展行高） ===== */
h1, h2, h3, h4 { text-wrap: balance; }
h1 { line-height: 1.2; letter-spacing: -.02em; }
h2 { line-height: 1.3; letter-spacing: -.015em; }
h3 { line-height: 1.38; letter-spacing: -.01em; }
h4 { line-height: 1.45; letter-spacing: -.005em; }
p { line-height: 1.7; }
/* 数字/统计等宽对齐，避免跳动 */
td, dd, progress, .metrics, .stat, [data-num] { font-feature-settings: "tnum" 1, "cv03" 1; font-variant-numeric: tabular-nums; }

/* ===== 通用表单元素 ===== */
button, input, select, textarea { max-width: 100%; }
select, input, textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 路由切换加载态：避免快速切屏时白屏/串屏 */
.route-loading {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(243, 244, 249, 0.72);
  backdrop-filter: blur(2px);
}
.route-loading[hidden] { display: none; }
.route-loading-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 26px 34px; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.route-loading-card p { margin: 0; color: var(--muted); font-size: 15px; }
.route-loading-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: route-spin 0.8s linear infinite;
}
@keyframes route-spin { to { transform: rotate(360deg); } }

.global-nav {
  position: sticky; top: 0; z-index: 1500;
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 10px clamp(16px, 2.4vw, 32px);
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.global-step,
.global-home {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid rgba(20, 24, 46, .12);
  background: #fff;
  color: var(--ink, #1d2233);
  transition: transform .15s, background .2s, border-color .2s, color .2s, opacity .2s;
}
.global-step:hover,
.global-home:hover {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.global-step:active, .global-home:active { transform: scale(.96); }
.global-step svg, .global-home svg { width: 16px; height: 16px; }
.global-step.is-disabled,
.global-step:disabled {
  opacity: .42; cursor: not-allowed;
  background: #f4f5f9; color: #8a90a6; border-color: rgba(20, 24, 46, .08);
}
.global-step.is-disabled:hover,
.global-step:disabled:hover { background: #f4f5f9; color: #8a90a6; border-color: rgba(20, 24, 46, .08); }
.global-home { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
@media (max-width: 700px) {
  .global-nav {
    gap: 6px;
    padding: 8px calc(12px + env(safe-area-inset-left));
  }
  .global-step, .global-home {
    padding: 8px 13px; font-size: 12px; min-height: 44px; gap: 5px;
  }
  .global-step span, .global-home span { display: inline; }
  .global-step svg, .global-home svg { width: 15px; height: 15px; }
  /* 移动端输入控件字号统一 16px，避免 iOS Safari 聚焦小于 16px 时自动放大页面 */
  input, select, textarea { font-size: 16px; }
}

@media (max-width: 640px) {
  /* 手机端不渲染全局「上一步 / 下一步 / 返回首页」工具条，交给浏览器与系统导航 */
  .global-nav { display: none !important; }
}

/* ===== 全局 sticky 顶栏统一接管「页面返回」，各模块内置页面返回按钮隐藏 ===== */
body > main[id] {
  flex: 1 0 auto;
  min-height: 100dvh;
}
body > .hanzi-learning { height: auto; }

/* 桌面端隐藏与全局导航重复的页面级返回按钮（保留刷新/报告/步骤等其它功能按钮）；
   手机端已取消全局导航条，页面自身的返回按钮保留，避免只能靠系统返回键 */
@media (min-width: 641px) {
.np-header [data-np="back"],
.ph-header .ph-back,
.gp-header > [data-gp="back"],
.ls-header > [data-ls="back"],
.rw-header > [data-rw="back"],
.wb-header > [data-wb="back"],
.wr-header > [data-wr="back"],
.pinyin-topbar .pn-icon-btn,
#real-papers-view .rp-back,
.tp-back,
.preview-back,
.assessment-back,
.pc-back,
.placeholder-back {
  display: none;
}
}

/* ===== 全局浏览器表面统一 ===== */
::selection { background: rgba(91, 95, 240, .22); color: #2b2f8a; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
/* 细圆角滚动条 */
* { scrollbar-width: thin; scrollbar-color: #c9cddb transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c9cddb; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aab0c4; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 单端在线被踢下线提示 ===== */
.session-kicked-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(20, 24, 46, .48);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.session-kicked-card {
  width: min(420px, 100%);
  text-align: center; padding: 34px 30px 30px;
  background: #fff; border-radius: 22px;
  box-shadow: 0 24px 60px rgba(20, 24, 46, .28);
  /* 仅做位移/缩放增强：即使动画被暂停，卡片仍保持可见，不依赖 opacity 填充 */
  animation: kicked-pop .28s cubic-bezier(.2, .9, .3, 1.2) both;
}
.session-kicked-badge {
  width: 64px; height: 64px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 34px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #fb7c3c, #fb5b6c);
  box-shadow: 0 10px 24px rgba(251, 91, 108, .38);
}
.session-kicked-card h2 { margin: 0 0 12px; font-size: 20px; font-weight: 800; color: #1d2233; }
.session-kicked-card p { margin: 0 0 24px; font-size: 14px; line-height: 1.7; color: #5b6472; }
.session-kicked-btn {
  width: 100%; min-height: 48px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #5b5ff0, #8b5cf6);
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 12px 26px rgba(91, 95, 240, .34);
  transition: transform .15s ease;
}
.session-kicked-btn:active { transform: scale(.97); }
@keyframes kicked-pop { from { transform: translateY(14px) scale(.96); } to { transform: none; } }

/* ===== 匿名锁定角标（首点即弹的视觉提示）===== */
.is-locked { position: relative; }
.lock-badge {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: rgba(91, 95, 240, .13);
  color: #5b5ff0;
  pointer-events: none;
}
.lock-badge svg { width: 15px; height: 15px; }
/* 深色侧栏项用浅色锁 */
.wb-rail-item.is-locked .lock-badge { background: rgba(255, 255, 255, .16); color: #fff; }
/* 移动端主按钮：锁垂直居中在右侧 */
.hx-bigbtn.is-locked .lock-badge { top: 50%; right: 14px; transform: translateY(-50%); }
/* 移动端快捷按钮无右上空间，锁放在右上角缩小 */
.hx-quick-btn.is-locked .lock-badge { top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 7px; }
.hx-quick-btn.is-locked .lock-badge svg { width: 13px; height: 13px; }
