/* 大江跃动 · 立体课堂 —— 全站样式
   版式思路：教材式的安静阅读页，交互区是唯一的视觉重点（深江蓝 + 琥珀高亮）。 */
:root {
  --bg: #f5f8f9;
  --surface: #ffffff;
  --ink: #13232b;
  --muted: #56676f;
  --line: #d9e2e6;
  --river: #0b5a73;
  --river-ink: #ffffff;
  --river-soft: #e2eff3;
  --spark: #c98a06;
  --spark-soft: #fbf1d9;
  --spark-ink: #8a5a00; /* 琥珀色文字（放在浅底上要够深，对比度 ≥ 4.5） */
  --good: #1f7a4d;
  --good-soft: #e1f3e9;
  --bad: #b23a2e;
  --bad-soft: #f8e4e1;
  --stage: #e9f0f2;
  --stage-grid: #d3dee2;

  --font-display: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-body: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --step-4: 2.75rem;
  --radius: 10px;
  --wrap: 1720px; /* 全站内容宽度上限：宽屏下尽量铺满，长段文字各自限宽 */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d161a; --surface: #132127; --ink: #e2ebee; --muted: #93a6ae; --line: #253840;
    --river: #5fc0db; --river-ink: #06222b; --river-soft: #15333d;
    --spark: #f0b43a; --spark-soft: #3a2e12; --spark-ink: #f0b43a;
    --good: #5fcf94; --good-soft: #13321f; --bad: #f08b7e; --bad-soft: #3c1a16;
    --stage: #091317; --stage-grid: #17272e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d161a; --surface: #132127; --ink: #e2ebee; --muted: #93a6ae; --line: #253840;
  --river: #5fc0db; --river-ink: #06222b; --river-soft: #15333d;
  --spark: #f0b43a; --spark-soft: #3a2e12; --spark-ink: #f0b43a;
  --good: #5fcf94; --good-soft: #13321f; --bad: #f08b7e; --bad-soft: #3c1a16;
  --stage: #091317; --stage-grid: #17272e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
/* 大屏上整体放大一点：所有用 rem 的字号、间距同比放大 */
@media (min-width: 1500px) { html { font-size: 106.25%; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.75;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--river); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--spark); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.3; text-wrap: balance; margin: 0; font-weight: 700; }
p { margin: 0; }
.en { font-family: var(--font-body); color: var(--muted); font-weight: 400; letter-spacing: 0.01em; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- 顶栏 ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; padding-block: 8px; }
/* 顶栏铺满整个屏幕宽度（只留少量边距），正文仍然居中限宽 */
.topbar .wrap { max-width: none; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
@media (max-width: 560px) { .topbar .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); } }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-mark { font-family: var(--font-display); font-weight: 800; font-size: 1.125rem; letter-spacing: 0.04em; }
.brand-mark b { color: var(--river); }
.ads { flex: 1 1 auto; min-width: 0; height: 44px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.ad-slot { position: relative; min-width: 0; height: 100%; overflow: hidden; border-radius: 8px; }
.ad-item { display: flex; align-items: center; justify-content: center; height: 100%; text-decoration: none; color: var(--ink); background: var(--bg); }
.ad-item img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ad-text { font-size: 0.875rem; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-slot.rolling .ad-track { transition: transform 0.6s ease; }
.ad-ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: var(--step--1); letter-spacing: 0.2em;
}
.topnav { display: flex; gap: 6px; align-items: center; flex: none; }
.topnav a, .theme-btn {
  font: inherit; font-size: 0.9375rem; color: var(--muted); text-decoration: none;
  padding: 6px 10px; border-radius: 8px; background: none; border: 0; cursor: pointer;
}
.topnav a:hover, .theme-btn:hover { color: var(--ink); background: var(--river-soft); }
/* 顶栏的登录、深色按钮：和专业、教材下拉框一样带边框，高度对齐 */
.topnav .theme-btn { border: 1px solid var(--line); background: var(--surface); line-height: inherit; }
.topnav .theme-btn:hover { border-color: var(--river); background: var(--surface); }
.brand-mark, .topnav a, .theme-btn { white-space: nowrap; }
.sel select {
  font: inherit; font-size: 0.9375rem; color: var(--ink); background-color: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 28px 6px 10px; cursor: pointer; max-width: 9em;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
.sel select:hover { border-color: var(--river); }
.sel select:disabled { color: var(--muted); cursor: not-allowed; }
/* 顶栏的专业、教材下拉框：未选时灰色提示文字，选定后点亮（两个框同一种样式） */
.sel select { color: var(--muted); }
.sel select.on { color: var(--river); font-weight: 600; }
.sel select option { color: var(--ink); font-weight: 400; }
.sel select option[value=""] { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px) {
  .topbar { position: static; }
  .topbar .wrap { flex-wrap: wrap; row-gap: 8px; }
  .topnav { margin-left: auto; }
  .ads { order: 3; flex-basis: 100%; height: 40px; }
}
@media (max-width: 560px) {
  .topnav .opt { display: none; }
  .topbar .wrap { gap: 8px; }
  .topnav { gap: 4px; }
  .topnav a, .theme-btn { padding: 6px 6px; }
  .sel select { max-width: 6.5em; padding-left: 8px; }
}
@media (max-width: 400px) { .brand-mark { font-size: 1rem; } .brand-logo { height: 26px; } .brand { gap: 8px; } .topnav { margin-left: 0; flex-basis: 100%; } }

/* ---------- 专业选择框（未选专业时） ---------- */
.gate { position: fixed; inset: 0; z-index: 60; background: rgb(8 20 26 / 0.55); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.gate-box { background: var(--surface); color: var(--ink); border-radius: 16px; padding: 28px 24px; width: min(560px, 100%); display: grid; gap: 12px; box-shadow: 0 20px 60px rgb(0 0 0 / 0.3); }
.gate-box h2 { font-size: var(--step-2); }
.gate-box p { color: var(--muted); }
.gate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.gate-b {
  font: inherit; text-align: center; cursor: pointer; display: grid; place-items: center; padding: 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.gate-b b { font-family: var(--font-display); font-size: var(--step-1); }
.gate-b small { color: var(--muted); font-size: 0.875rem; }
.gate-b:hover { border-color: var(--river); background: var(--river-soft); }
@media (max-width: 420px) { .gate-grid { grid-template-columns: 1fr; } }

/* ---------- 面包屑 ---------- */
.crumbs { font-size: var(--step--1); color: var(--muted); padding-block: 18px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.crumbs span[aria-hidden] { opacity: 0.5; }

/* ---------- 按钮、标签 ---------- */
.btn {
  font: inherit; font-size: 0.9375rem; line-height: 1.2;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--river); color: var(--river); }
.btn.primary { background: var(--river); border-color: var(--river); color: var(--river-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--river-ink); }
/* 切换类按钮的选中状态：和分段按钮（球棍/空间填充）一样实心高亮 */
.btn[aria-pressed="true"], .btn[aria-pressed="true"]:hover { background: var(--river); border-color: var(--river); color: var(--river-ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.chip {
  display: inline-block; font-size: 0.8125rem; line-height: 1; padding: 5px 8px; border-radius: 999px;
  background: var(--river-soft); color: var(--river); letter-spacing: 0.04em; white-space: nowrap;
}
.chip.live { background: var(--good-soft); color: var(--good); }
.chip.soon { background: transparent; color: var(--muted); border: 1px dashed var(--line); }

/* ---------- 专业门类选择 ---------- */
.major-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.major-picker .mp-label { font-size: 0.875rem; font-weight: 600; margin-right: 4px; }
.major-picker button {
  font: inherit; font-size: 0.875rem; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.major-picker button:hover { border-color: var(--river); color: var(--ink); }
.major-picker button[aria-pressed="true"] { background: var(--river); border-color: var(--river); color: var(--river-ink); }
.major-picker .mp-hint { font-size: 0.875rem; color: var(--muted); margin-left: 4px; }

/* ---------- 术语（中英对照） ---------- */
dfn.term {
  font-style: normal; font-weight: 600; color: var(--ink);
  border-bottom: 1.5px dotted var(--river); cursor: help; position: relative;
}
.term-tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--bg);
  font-size: 0.875rem; line-height: 1.4; padding: 6px 10px; border-radius: 6px;
  max-width: 260px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}
.term-tip small { display: block; opacity: 0.75; font-size: 0.8125rem; }

/* ---------- 页脚 ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 72px; padding-block: 28px 40px; color: var(--muted); font-size: var(--step--1); }
.foot .wrap { display: grid; gap: 6px; }
.foot .beian { text-align: center; font-size: 0.875rem; margin-top: 6px; }
.foot .beian a { color: inherit; text-underline-offset: 3px; }
.copyright { margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--line); display: grid; gap: 4px; line-height: 1.7; }
.copyright b { color: var(--ink); font-weight: 600; }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--river); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 报错反馈 ---------- */
/* 右下角两个悬浮按钮做成 44px 圆形：宽屏落在内容区右侧的留白里，手机上少挡内容 */
.fb-fab, .top-fab {
  position: fixed; z-index: 40;
  right: max(16px, env(safe-area-inset-right, 0px));
  width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
  font: inherit; font-size: 0.8125rem; font-weight: 600; line-height: 1; border-radius: 50%; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 6px 18px rgb(0 0 0 / 0.12);
}
.fb-fab { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.fb-fab:hover, .top-fab:hover { border-color: var(--river); color: var(--river); }
/* 返回顶部：叠在"报错反馈"上方，页面往下滚动一段后才出现 */
.top-fab {
  bottom: calc(68px + env(safe-area-inset-bottom, 0px)); font-size: 1.125rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.top-fab.off { opacity: 0; transform: translateY(8px); pointer-events: none; }
/* 手机：页脚底部留出悬浮按钮的位置 */
@media (max-width: 900px) { .foot { padding-bottom: 120px; } }
.fb-modal { position: fixed; inset: 0; z-index: 70; background: rgb(8 20 26 / 0.5); display: grid; place-items: center; padding: 16px; }
.fb-box { background: var(--surface); color: var(--ink); width: min(520px, 100%); max-height: calc(100% - 32px); overflow: auto; border-radius: 14px; padding: 22px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgb(0 0 0 / 0.3); }
.fb-box h2 { font-size: var(--step-1); }
.fb-where { font-size: 0.875rem; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.fb-kinds { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.fb-kinds legend { font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; padding: 0; }
.fb-kinds label { display: inline-flex; align-items: center; gap: 4px; font-size: 0.875rem; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.fb-kinds label:has(input:checked) { border-color: var(--river); background: var(--river-soft); color: var(--river); }
.fb-field { display: grid; gap: 4px; font-size: 0.875rem; font-weight: 600; }
.fb-field small { font-weight: 400; color: var(--muted); }
.fb-field textarea, .fb-field input { font: inherit; font-weight: 400; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.fb-field textarea:focus, .fb-field input:focus { outline: none; border-color: var(--river); }
.fb-msg { font-size: 0.875rem; min-height: 1.4em; }
.fb-msg.bad { color: var(--bad); }
.fb-msg.good { color: var(--good); }
.fb-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 直接双击 html 文件打开时的提示条 ---------- */
.file-warn {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px;
  padding: 10px 16px; background: var(--spark-soft); color: var(--ink); border-bottom: 1px solid var(--spark);
}
.file-warn code { font-family: var(--font-mono); background: var(--surface); padding: 0 4px; border-radius: 4px; }

/* ---------- 课堂演示模式（网址加 ?present） ---------- */
html.present { font-size: 118.75%; } /* 投影时字更大 */
html.present .topbar, html.present .crumbs, html.present .foot,
html.present .fb-fab, html.present .top-fab, html.present body::before { display: none; }
html.present .wrap { max-width: none; padding-left: 24px; padding-right: 24px; }
.present-bar { position: fixed; z-index: 45; top: 10px; right: 16px; display: flex; gap: 6px; opacity: 0.45; transition: opacity 0.2s ease; }
.present-bar:hover, .present-bar:focus-within { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* 上下标不撑开行高 */
sub, sup { font-size: 0.72em; line-height: 0; position: relative; vertical-align: baseline; }
sub { bottom: -0.3em; }
sup { top: -0.45em; }

/* ---------- 学生账号：顶栏按钮、登录框、个人中心（弹窗外壳沿用 .fb-modal / .fb-box） ---------- */
/* 登录按钮：始终蓝色加粗（和选定后的专业、教材框同色）；登录后显示“我的”，样式不变 */
.acct-btn, .acct-btn:hover { color: var(--river); font-weight: 600; }
.acct-box { width: min(440px, 100%); }
.acct-box h2 { margin: 0; }
.acct-reason { font-size: 0.9375rem; color: var(--ink); background: var(--river-soft); border-radius: 8px; padding: 8px 10px; }
.acct-sub, .acct-note { font-size: 0.875rem; color: var(--muted); }
.acct-form { display: grid; gap: 12px; }
.acct-row { display: flex; gap: 8px; }
.acct-row input { flex: 1; min-width: 0; }
.acct-row .btn { flex: none; white-space: nowrap; padding-inline: 12px; }
.acct-box input[readonly] { color: var(--muted); }
.acct-agree { display: flex; gap: 8px; align-items: flex-start; font-size: 0.875rem; line-height: 1.6; cursor: pointer; }
.acct-agree input { margin-top: 0.3em; flex: none; width: 16px; height: 16px; }
.acct-agree a { color: var(--river); }
.acct-dev { font-size: 0.875rem; background: var(--spark-soft); border: 1px solid var(--spark); border-radius: 8px; padding: 8px 10px; }
.acct-slider { display: grid; gap: 6px; font-size: 0.875rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.acct-slider input { width: 100%; accent-color: var(--river); height: 28px; }
.acct-slider small { color: var(--muted); }
.acct-box .fb-actions { flex-wrap: wrap; }
.acct-forgot { margin-right: auto; }
.acct-info { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 0.9375rem; margin: 0; }
.acct-info dt { color: var(--muted); }
.acct-info dd { margin: 0; }
.acct-pwform { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.acct-del { font-size: 0.875rem; border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 8px; }
.acct-del summary { cursor: pointer; color: var(--muted); }
.acct-del p { color: var(--muted); line-height: 1.6; margin: 8px 0; }
.acct-delgo { color: var(--bad); border-color: var(--bad); }
