/* Author: SystemTools团队 | 制作时间: 2026-09-04 */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1c2333;
  --muted: #7c8498;
  --primary: #4c6ef5;
  --primary-dark: #3b5bdb;
  --ok: #2f9e44;
  --danger: #e03131;
  --warn: #f59f00;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --bar-band: rgba(255,255,255,.9); /* 顶栏/页脚底 */
  --meter-track: #e9ecf2;           /* 进度条轨道 */
  --map-bg: #eef1f6;                /* 中国地图背景（柔和灰，适合高亮屏） */
  --map-site: #d6dbe4;              /* 地图无访问省份底色 */
  --map-hover: rgba(96,104,121,.55);
}
html[data-theme="dark"] {
  --bg: #0f1117; --card: #191d27; --border: #2a2f3d;
  --text: #e7eaf1; --muted: #98a1b4;
  --primary: #5b7cfc; --primary-dark: #7c92ff;
  --ok: #51cf66; --danger: #ff6b6b; --warn: #ffc34d;
  --shadow: 0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.35);
  --bar-band: rgba(18,21,28,.78);
  --meter-track: #2a2f39;
  --map-bg: #14161d;
  --map-site: #2b303a;
  --map-hover: rgba(198,204,216,.5);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: 38px; /* 给固定版权栏留出空间 */
}

/* 固定底部版权栏 */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  text-align: center; font-size: 12px; color: var(--muted);
  background: var(--bar-band); border-top: 1px solid var(--border);
  padding: 7px 12px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--bar-band);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #4c6ef5, #22b8cf);
  color: #fff; font-weight: 800;
}
.brand-name span { color: var(--primary); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  border: none; background: transparent; cursor: pointer;
  padding: 8px 14px; border-radius: 9px;
  color: var(--muted); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab:hover { background: #eef1f8; color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

/* 右上角主题切换按钮 */
.theme-toggle {
  margin-left: auto; display: grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); cursor: pointer;
  font-size: 17px; line-height: 1;
}
.theme-toggle:hover { border-color: var(--primary); }
.theme-toggle span { pointer-events: none; }
html[data-theme="dark"] .theme-toggle .tt-sun,
html:not([data-theme="dark"]) .theme-toggle .tt-moon { display: none; }

/* 深色模式 hover/轨道 补色 */
html[data-theme="dark"] .tab:hover,
html[data-theme="dark"] .tag,
html[data-theme="dark"] .toolbar button:hover { background: #262b36; }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }
.page { display: none; }
.page.active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px;
}
.card-title { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head-fields { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.form-actions.span-2 { grid-column: span 4; }
.hint { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(76,110,245,.12); }
.input { width: 100%; }
.select { min-width: 120px; }
.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all .15s;
}
.btn:hover { border-color: #c9d2e5; background: #f7f9fd; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: #2b8a3e; }
.btn.danger { color: var(--danger); border-color: #f1c2c2; }
.btn.danger:hover { background: #fff0f0; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.block { width: 100%; }

.onboard .card-title { display: flex; align-items: center; gap: 8px; }
.onboard-list { margin: 8px 0 14px; padding-left: 20px; line-height: 1.8; }
.onboard-list b { color: var(--primary); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfe; }
.table tr:hover td { background: #f8faff; }
.empty { color: var(--muted); text-align: center; padding: 18px !important; }
.pad { padding: 40px 20px; }
.score-ok { color: var(--ok); font-weight: 600; }
.score-bad { color: var(--danger); font-weight: 600; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef1f8; color: var(--muted); font-size: 12px; }
.pill { display: inline-block; width: 64px; height: 8px; border-radius: 4px; background: #edf0f7; overflow: hidden; vertical-align: middle; }
.pill > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn {
  border: 1px solid var(--border); background: #fff; cursor: pointer;
  padding: 3px 9px; border-radius: 6px; font-size: 12px; color: var(--muted);
}
.mini-btn:hover { border-color: var(--primary); color: var(--primary); }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 统计卡 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 4px; }

/* ---------- 图表 ---------- */
.chart { height: 320px; position: relative; }
.chart svg { width: 100%; height: 100%; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- 笔记 ---------- */
.notes-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.notes-side { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 12px; }
.note-list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.note-list li {
  padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px;
  cursor: pointer; background: #fff; transition: border-color .15s;
}
.note-list li:hover { border-color: #bcd0ff; }
.note-list li.active { border-color: var(--primary); background: #f3f6ff; }
.note-list b { display: block; font-size: 14px; }
.note-list small { color: var(--muted); font-size: 12px; }
.notes-editor { margin: 0; }
.note-title { width: 100%; font-size: 20px; font-weight: 700; border: none; padding: 6px 0; margin-bottom: 8px; box-shadow: none !important; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.toolbar button {
  min-width: 34px; padding: 5px 9px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; cursor: pointer; font-size: 14px; color: var(--text);
}
.toolbar button:hover { background: #eef1f8; }
.toolbar .sep { width: 1px; background: var(--border); margin: 0 6px; }
.note-content {
  min-height: 320px; outline: none; padding: 4px 2px; font-size: 15px; line-height: 1.75;
}
.note-content img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.note-content h2 { font-size: 1.3em; margin: 14px 0 8px; }
.note-content blockquote { border-left: 3px solid var(--primary); margin: 8px 0; padding: 4px 12px; color: var(--muted); background: #f7f9fd; }
.note-content ul, .note-content ol { padding-left: 22px; }

/* ---------- 拼写 ---------- */
.spell-card { min-height: 320px; }
.spell-question { text-align: center; padding: 12px 0 4px; }
.spell-progress { height: 6px; background: #edf0f7; border-radius: 3px; overflow: hidden; margin-bottom: 18px; }
.spell-progress > i { display: block; height: 100%; background: var(--primary); transition: width .3s; }
.spell-meaning { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.spell-example { color: var(--muted); font-style: italic; margin-bottom: 22px; min-height: 22px; }
.spell-input {
  font-family: var(--mono); font-size: 22px; text-align: center;
  width: min(420px, 100%); padding: 12px 14px; border-radius: 10px;
}
.spell-feedback { margin-top: 18px; font-size: 18px; min-height: 28px; }
.spell-feedback.right { color: var(--ok); }
.spell-feedback.wrong { color: var(--danger); }

/* ---------- 弹窗/闪卡 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16,24,40,.45); display: grid; place-items: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto; overflow-x: hidden;
  background: #fff; border-radius: var(--radius); padding: 22px 24px;
}
.modal .card-head { margin-top: 0; }
/* 弹窗内表单用更宽敞的两列布局，避免列宽被输入框最小宽度撑破 */
.modal .form-grid { grid-template-columns: 1fr 1fr; }
.modal .form-actions.span-2 { grid-column: span 2; }
.flash-card {
  cursor: pointer; user-select: none; min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: 12px; padding: 24px; text-align: center;
  transition: background .2s;
}
.flash-card:hover { background: #fafbfe; }
.flash-word { font-size: 40px; font-weight: 800; }
.flash-phonetic { color: var(--primary); font-size: 18px; margin-bottom: 8px; }
.flash-meaning { font-size: 24px; font-weight: 600; margin-bottom: 14px; }
.flash-example { color: var(--muted); font-style: italic; }
.flash-actions { display: flex; gap: 12px; margin-top: 22px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c2333; color: #fff; padding: 10px 18px; border-radius: 9px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-actions.span-2 { grid-column: span 2; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .notes-layout { grid-template-columns: 1fr; }
  .notes-side { position: static; }
}
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-actions.span-2 { grid-column: span 1; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ---------- 动态效果 ---------- */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes flipY {
  0% { transform: perspective(700px) rotateY(90deg); opacity: .4; }
  60% { opacity: 1; }
  100% { transform: perspective(700px) rotateY(0); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loaderSlide { from { width: 0; } to { width: 100%; } }

/* 页面切换 */
.page.active { animation: pageIn .30s ease; }

/* 卡片悬浮 */
.card, .stat { transition: transform .18s ease, box-shadow .18s ease; }
.card:hover, .stat:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(16,24,40,.10); }
.stat { cursor: default; }

/* 按钮按压微交互 */
.btn { position: relative; overflow: hidden; transition: transform .12s ease, box-shadow .12s ease, background .15s, border-color .15s; }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn.primary:active:not(:disabled) { box-shadow: inset 0 0 0 99px rgba(0,0,0,.08); }
.mini-btn { transition: transform .1s ease, color .15s, border-color .15s; }
.mini-btn:active { transform: scale(.94); }

/* 导航 tab 微缩放 */
.tab { transition: background .15s, color .15s, transform .1s; }
.tab:active { transform: scale(.95); }

/* 表格与笔记列表条目淡入 */
.table tbody tr { animation: fadeUp .28s ease both; }
.note-list li { animation: fadeUp .26s ease both; }

/* 统计数字 */
.stat .v { display: inline-block; font-variant-numeric: tabular-nums; }

/* 图表：折线动画 + 数据点弹入 */
.chart polyline { stroke-dasharray: 100; stroke-dashoffset: 100; animation: drawLine .95s ease-out forwards; }
.chart circle { animation: popIn .4s ease both; }

/* 弹窗出现 */
.modal-backdrop { animation: fadeUp .2s ease; }
.modal { animation: popIn .24s ease; }

/* 闪卡翻转 */
.flash-card.flip-anim { animation: flipY .3s ease; }
.flash-front, .flash-back { transition: opacity .15s; }

/* 加载进度条 */
.loader-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, #4c6ef5, #22b8cf);
  z-index: 200; border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(76,110,245,.6);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, width .4s ease;
}
.loader-bar.on { opacity: 1; width: 100%; animation: loaderSlide 1.1s cubic-bezier(.4,0,.2,1) forwards; }

/* 输入框聚焦微光 */
input:focus, select:focus, textarea:focus {
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

/* 尊重系统减弱动态偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}

/* ---------- 学业阶段 ---------- */
.stage-switch { position: relative; }
.stage-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: #fff;
  color: var(--text); transition: border-color .15s, background .15s, transform .1s;
}
.stage-btn:hover { border-color: var(--primary); background: #eef3ff; }
.stage-btn:active { transform: scale(.96); }
.stage-caret { color: var(--muted); font-size: 12px; }
.stage-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  width: max-content; padding: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 24px rgba(16,24,40,.12);
  animation: fadeUp .18s ease;
}
.stage-menu[hidden] { display: none; }
.stage-menu a, .stage-menu button {
  border: none; background: transparent; padding: 8px 14px; border-radius: 8px;
  font-size: 14px; cursor: pointer; color: var(--text); white-space: nowrap;
  transition: background .12s, color .12s;
}
.stage-menu button:hover { background: #eef3ff; color: var(--primary); }

.stage-modal-body { width: min(460px, 100%); }
.stage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.stage-opt {
  padding: 20px 10px; font-size: 16px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: #f8f9fc;
  color: var(--text); transition: transform .15s, border-color .15s, background .15s, box-shadow .15s;
}
.stage-opt:hover {
  border-color: var(--primary); background: #eef3ff; color: var(--primary);
  transform: translateY(-2px); box-shadow: 0 6px 14px rgba(76,110,245,.18);
}
.stage-opt:active { transform: translateY(0) scale(.97); }

/* 首次选择学业：弹窗从中间向右上角缩小变淡直至消失 */
#stage-modal.closing { animation: stageBackFade .5s forwards; }
#stage-modal.closing .modal { animation: stageFlyOut .5s cubic-bezier(.55, .06, .9, .4) forwards; }
@keyframes stageBackFade { to { background: rgba(16, 24, 40, 0); } }
@keyframes stageFlyOut {
  to { transform: translate(min(38vw, 320px), -48vh) scale(.12); opacity: 0; }
}

/* ---------- 运行日志面板 ---------- */
.logs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.logs-grid .wide { grid-column: 1 / -1; }
.kpi { text-align: center; margin: 6px 0; }
.kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi-num { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.kpi-lab { color: var(--muted); font-size: 13px; margin-top: 2px; }
.meter-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.meter { flex: 1; height: 10px; border-radius: 999px; background: var(--meter-track); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0%; background: var(--primary); border-radius: 999px; transition: width .5s ease; }
.meter-lab { width: 52px; color: var(--muted); font-size: 13px; }
.meter-num { min-width: 86px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.dist-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
.world-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.dist-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dist-name { width: 84px; text-align: right; font-weight: 600; white-space: nowrap; }
.dist-meter { flex: 1; height: 9px; }
.dist-num { width: 52px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.china-card { text-align: center; }
.china-map { background: var(--map-bg); border-radius: 12px; padding: 10px 6px; }
.china-map svg { width: 100%; height: auto; max-height: 440px; }
.china-map path { transition: fill .25s; }
.china-map path:hover { fill: var(--map-hover); }

@media (max-width: 900px) {
  .logs-grid { grid-template-columns: 1fr; }
  .dist-layout { grid-template-columns: 1fr; }
}