:root {
  --bg: #f3f4fb;
  --card: #ffffff;
  --ink: #1f2340;
  --muted: #7b7f99;
  --primary: #5b5bd6;
  --primary-dark: #4646b8;
  --accent: #ffb547;
  --solved: #22a06b;
  --solved-bg: #e3f7ee;
  --blank-bg: #eef0fa;
  --locked-bg: #f7f8fd;
  --danger: #e5484d;
  --line: #e3e5f2;
  --hl: #fff3d6;
  --radius: 14px;
  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #eef0ff 0%, #f6f3ff 45%, #fdf6ec 100%);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.brand h1 { font-size: 20px; letter-spacing: 1px; }
.brand h1 .en { font-size: 13px; color: var(--primary); font-weight: 600; margin-left: 4px; }
.slogan { font-size: 12px; color: var(--muted); margin-top: 2px; }
.top-stats { display: flex; gap: 22px; align-items: center; }
.stat { text-align: center; min-width: 64px; }
.stat span { font-size: 18px; font-weight: 700; color: var(--primary); }
.stat label { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.home-link { margin-left: 8px; padding: 6px 12px; border-radius: 8px; font-size: 13px;
  color: var(--primary); text-decoration: none; border: 1px solid var(--border); background: var(--card); }
.home-link:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 18px;
  padding: 18px 24px;
  max-width: 1480px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  min-height: 0;       /* 允许子列在 flex 容器内收缩，从而各自出现滚动条 */
  align-items: stretch;
}
.left-col, .right-col {
  display: flex; flex-direction: column; gap: 18px; min-width: 0;
  min-height: 0;
  overflow-y: auto;    /* 左右两栏各自独立滚动 */
  overscroll-behavior: contain;
  padding-right: 4px;
  padding-bottom: 24px;
  scrollbar-width: thin;
  scrollbar-color: #c3c7e6 transparent;
}
.left-col::-webkit-scrollbar, .right-col::-webkit-scrollbar { width: 8px; }
.left-col::-webkit-scrollbar-track, .right-col::-webkit-scrollbar-track { background: transparent; }
.left-col::-webkit-scrollbar-thumb, .right-col::-webkit-scrollbar-thumb {
  background: #c3c7e6; border-radius: 999px;
}
.left-col::-webkit-scrollbar-thumb:hover, .right-col::-webkit-scrollbar-thumb:hover { background: var(--primary); }
.card { flex-shrink: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 4px 18px rgba(60,60,130,.06);
}
.card h2 { font-size: 15px; margin-bottom: 8px; }
.article-tip { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* ---------- 段落导航控件 ---------- */
.seg-ctrl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.seg-ctrl .ctl {
  flex: 1 1 200px;
  min-width: 0;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.seg-nav { display: flex; align-items: center; gap: 6px; }
.seg-btn {
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  color: var(--primary);
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.seg-btn:hover { background: var(--blank-bg); }
.seg-btn:active { transform: scale(.94); }
.seg-rand { width: auto; padding: 0 9px; font-size: 13px; }
.seg-label {
  font-size: 12.5px;
  color: var(--muted);
  min-width: 78px;
  text-align: center;
  white-space: nowrap;
}
.passage-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

/* ---------- 文章 ---------- */
.article {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14.5px;
  line-height: 1.85;
  color: #34395c;
  text-align: justify;
}
.article mark {
  background: var(--hl);
  border-bottom: 2px solid var(--accent);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
  color: #7a4d00;
  animation: pop .4s ease;
}
.article .article-def {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  color: var(--solved);
  background: var(--solved-bg);
  border-radius: 4px;
  padding: 0 4px;
  margin: 0 2px;
  white-space: nowrap;
  animation: pop .4s ease;
}
.article mark.raw {
  background: #fff0f3;
  border-bottom-color: #e0457b;
  color: #b01e57;
}
.article mark.raw + .article-def { color: #b01e57; background: #ffe6ee; }

/* ---------- 生词推理链（弹窗） ---------- */
.modal-chain-wrap {
  margin: 10px 0 2px;
  text-align: left;
}
.modal-method {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #b01e57;
  background: #ffe6ee;
  border: 1px solid #f3b9cf;
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 6px;
}
.modal-chain {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12.5px;
  line-height: 1.7;
  color: #6b3a4a;
  background: #fff7fa;
  border-left: 3px solid #e0457b;
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  margin: 0;
}

/* ---------- 生词徽标（单词列表） ---------- */
.raw-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #e0457b;
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 5px;
  vertical-align: middle;
}

/* ---------- 路径列表 ---------- */
.path-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.review-config {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 4px 0 12px; padding: 8px 12px;
  background: #f7f7ff; border: 1px dashed #c8cdf0; border-radius: 10px;
}
.review-config .rc-label { font-size: 13px; font-weight: 700; color: var(--primary); }
.rc-opt {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none;
}
.rc-opt input { accent-color: var(--primary); }
.path-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  font-size: 13px;
}
.path-item:hover { border-color: var(--primary); background: #f6f6ff; }
.path-item.active { border-color: var(--primary); background: #efefff; box-shadow: 0 0 0 2px rgba(91,91,214,.15); }
.path-item .dir-badge {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: #efefff;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}
.path-item.solved .dir-badge { background: var(--solved-bg); color: var(--solved); }
.path-item .p-info { flex: 1; min-width: 0; }
.path-item .p-name { font-weight: 700; letter-spacing: .5px; }
.path-item .p-name .p-word { color: var(--solved); }
.path-item .p-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.path-item .p-state { font-size: 12px; flex-shrink: 0; }
.path-item.solved { background: #f4fcf8; border-color: #bfe8d6; }

/* ---------- 方格阵 ---------- */
.grid-card { overflow: hidden; }
.grid-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.toolbar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--primary); }
.legend { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.legend .lg { width: 13px; height: 13px; border-radius: 4px; display: inline-block; margin-left: 10px; margin-right: 3px; border: 1px solid var(--line); }
.lg-locked { background: var(--locked-bg); }
.lg-blank { background: var(--blank-bg); border-color: #c8cdf0 !important; }
.lg-solved { background: var(--solved-bg); border-color: #bfe8d6 !important; }

.grid-wrap { overflow-x: auto; padding-bottom: 4px; }
.grid {
  display: grid;
  gap: 3px;
  width: max-content;
  margin: 0 auto;
}
.cell {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  font-weight: 700;
  font-size: 15px;
  user-select: none;
  position: relative;
  transition: background .15s, box-shadow .15s, color .15s;
}
.cell.empty { background: transparent; }
.cell.filler { background: transparent; color: #c2c5da; font-weight: 500; }
.cell.word { background: var(--locked-bg); border: 1px solid var(--line); cursor: pointer; }
.cell.word.blank { background: var(--blank-bg); border-color: #c8cdf0; }
.cell.word.blank::after {
  content: ""; position: absolute; bottom: 5px; left: 8px; right: 8px;
  height: 2px; border-radius: 2px; background: #aab0e0;
}
.cell.word.blank.filled::after { display: none; }
.cell .u-letter { color: var(--primary); }
.cell.word.solved { background: var(--solved-bg); border-color: #bfe8d6; color: var(--solved); }
.cell.word.solved::after { display: none; }
.cell.hl { box-shadow: 0 0 0 2px var(--primary); background: #e9e9ff; z-index: 2; }
.cell.hl.solved { box-shadow: 0 0 0 2px var(--solved); }
.cell.hl-focus { background: var(--accent) !important; color: #5b3c00 !important; box-shadow: 0 0 0 2px var(--accent); }
.cell.flash-ok { animation: flashOk .7s ease; }
@keyframes flashOk { 0% { background: var(--accent); } 100% { background: var(--solved-bg); } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ---------- 作答面板 ---------- */
.panel-empty { color: var(--muted); font-size: 13.5px; line-height: 2; text-align: center; padding: 16px 0; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head .dir-badge {
  background: #efefff; color: var(--primary);
  padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 700;
}
.panel-head .p-meta { font-size: 13px; color: var(--muted); }
.slot-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.slot {
  width: 42px; height: 48px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800;
  border: 1.5px solid var(--line);
  background: var(--locked-bg);
  color: var(--ink);
  position: relative;
}
.slot .slot-idx {
  position: absolute; top: 2px; left: 5px;
  font-size: 9px; color: #b5b9d4; font-weight: 600;
}
.slot.given { background: #fff; }
.slot.solved { background: var(--solved-bg); border-color: #bfe8d6; color: var(--solved); }
.slot input {
  width: 100%; height: 100%;
  border: none; outline: none; background: transparent;
  text-align: center; font-size: 20px; font-weight: 800;
  color: var(--primary); text-transform: lowercase;
  caret-color: var(--primary);
  font-family: inherit;
}
.slot.input-slot { background: var(--blank-bg); border-color: #c8cdf0; cursor: text; }
.slot.input-slot:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,91,214,.18); }
.slot.wrong { border-color: var(--danger); background: #fdeeee; animation: shake .3s ease; }
.slot.wrong input { color: var(--danger); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: none; border-radius: 10px;
  padding: 9px 20px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #efefff; color: var(--primary); }
.btn-ghost:hover { background: #e3e3fc; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.panel-msg { font-size: 13px; margin-left: 4px; }
.panel-msg.err { color: var(--danger); }
.panel-msg.ok { color: var(--solved); }
.panel-solved-meaning {
  margin-top: 4px;
  background: var(--solved-bg);
  border: 1px solid #bfe8d6;
  color: #14724b;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(30,32,60,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff;
  border-radius: 18px;
  padding: 30px 38px;
  text-align: center;
  max-width: 420px;
  width: calc(100% - 48px);
  box-shadow: 0 20px 60px rgba(30,32,80,.25);
  animation: modalIn .28s cubic-bezier(.2,1.2,.4,1);
}
@keyframes modalIn { from { transform: scale(.8) translateY(14px); opacity: 0; } }
.modal-icon { font-size: 44px; }
.modal h3 { margin: 8px 0 14px; font-size: 18px; }
.modal-word {
  font-size: 30px; font-weight: 800; letter-spacing: 2px;
  color: var(--primary);
  margin-bottom: 8px;
}
.modal-meaning { font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.modal-extra { font-size: 12.5px; color: var(--muted); margin-bottom: 18px; line-height: 1.7; }
.modal-audio { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.btn-audio {
  background: #fff; color: var(--primary);
  border: 1.5px solid var(--primary); border-radius: 999px;
  padding: 8px 18px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .15s;
}
.btn-audio:hover { background: var(--primary); color: #fff; }
.btn-audio:active { transform: scale(.96); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  body { height: auto; overflow: auto; display: block; }
  .layout { grid-template-columns: 1fr; }
  .left-col, .right-col { overflow-y: visible; min-height: auto; padding-right: 0; padding-bottom: 0; }
  .left-col { order: 2; }
  .right-col { order: 1; }
  .topbar { position: sticky; top: 0; }
}

/* ---------- 参考资源页脚 ---------- */
.ref-footer {
  flex-shrink: 0;
  padding: 10px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.55);
  border-top: 1px solid var(--line);
}
.ref-inner { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.ref-label { font-weight: 700; color: var(--primary); }
.ref-footer a { color: var(--primary); text-decoration: none; }
.ref-footer a:hover { text-decoration: underline; }
.ref-sep { color: #d0d2e0; }

/* ---------- 释义反馈（弹窗内） ---------- */
.modal-feedback { margin-top: 14px; }
.btn-feedback {
  background: transparent; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px;
  padding: 6px 16px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-feedback:hover { border-color: var(--primary); color: var(--primary); background: #f6f6ff; }
#feedback-form {
  margin-top: 10px; text-align: left;
  background: #fafaff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.feedback-tip { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
#feedback-text {
  width: 100%; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .15s;
  background: #fff; color: var(--ink);
}
#feedback-text:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,91,214,.15); }
.feedback-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.feedback-actions .btn { padding: 6px 14px; font-size: 13px; }
.feedback-msg { font-size: 12px; margin-top: 6px; min-height: 18px; }
.feedback-msg.ok { color: var(--solved); }
.feedback-msg.err { color: var(--danger); }
