/* ============================================================
   中级序列练习 · Web 版样式
   浅色 / 深色双主题，纯手写，无任何外部依赖
   ============================================================ */

:root {
  --bg: #f4f6fa;
  --bg-soft: #eef1f7;
  --card: #ffffff;
  --text: #1b2533;
  --text-soft: #4d5b6e;
  --muted: #7d8a9c;
  --line: #e2e7ef;
  --brand: #2f6df6;
  --brand-soft: #eaf0ff;
  --brand-deep: #1f52c9;
  --ok: #15a05a;
  --ok-soft: #e8f7ef;
  --bad: #d93b3b;
  --bad-soft: #fdecec;
  --warn: #c98a16;
  --shadow: 0 1px 2px rgba(20, 32, 54, .06), 0 8px 24px rgba(20, 32, 54, .06);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #10151d;
  --bg-soft: #161d27;
  --card: #1a2230;
  --text: #e8edf5;
  --text-soft: #b6c2d3;
  --muted: #7f8ea3;
  --line: #263244;
  --brand: #5b8dff;
  --brand-soft: #1e2c48;
  --brand-deep: #8fb0ff;
  --ok: #3fc681;
  --ok-soft: #16352a;
  --bad: #ff6b6b;
  --bad-soft: #3a1f22;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 190px; }

.logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--brand), #7aa2ff);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 6px 16px rgba(47, 109, 246, .28);
}

.brand-text h1 { margin: 0; font-size: 17px; letter-spacing: .3px; }
.brand-text p { margin: 0; font-size: 12px; color: var(--muted); }

.chips { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }

.chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.chip b { color: var(--text); font-size: 14px; font-weight: 650; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
}
.icon-btn:hover { border-color: var(--brand); }

/* ---------------- 标签页 ---------------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 24px 0;
  max-width: 1240px;
  margin: 0 auto;
}

.tab {
  position: relative;
  padding: 9px 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: 10px 10px 0 0;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); font-weight: 650; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  background: var(--brand);
  border-radius: 2px;
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 9px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 11px;
  line-height: 17px;
  text-align: center;
}

/* ---------------- 主体 ---------------- */

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 24px 60px;
}

.view { display: block; }
.view[hidden] { display: none !important; }

#view-practice {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ---------------- 侧栏面板 ---------------- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel.wide-panel { max-width: 1080px; margin: 0 auto; }

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  letter-spacing: .3px;
}

.setup { position: sticky; top: 86px; }

.field {
  display: block;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.field > span, .field { font-weight: 500; }

select, input, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { resize: vertical; line-height: 1.5; font-size: 13px; }

.field[hidden], .sub[hidden] { display: none; }

.primary, .ghost {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.primary {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(47, 109, 246, .22);
}
.primary:hover { background: var(--brand-deep); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.ghost {
  background: var(--bg-soft);
  border-color: var(--line);
  color: var(--text-soft);
}
.ghost:hover { border-color: var(--brand); color: var(--brand); }
.ghost.danger:hover { border-color: var(--bad); color: var(--bad); }

.wide { width: 100%; }

/* ---------------- 未完成 / 最近 ---------------- */

.resume, .recent { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.resume h3, .recent h3 { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); font-weight: 600; }

.resume-item, .recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 12.5px;
}
.resume-item .ri-label { color: var(--text); font-weight: 550; }
.resume-item .ri-sub, .recent-item span { color: var(--muted); font-size: 11.5px; }
.resume-item button {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.resume-item button:hover { background: var(--brand); color: #fff; }

/* ---------------- 空状态 ---------------- */

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 54px 30px;
  text-align: center;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 6px; }
.empty h2 { margin: 0 0 8px; font-size: 17px; color: var(--text); font-weight: 600; }
.empty p { margin: 0 auto; max-width: 460px; font-size: 13.5px; }
.empty-tips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.empty-tips span {
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--text-soft);
}

/* ---------------- 题卡 ---------------- */

.qcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px 18px;
}

.qhead { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.qtype {
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  font-size: 11.5px;
}
.qmeta { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcount { font-variant-numeric: tabular-nums; color: var(--text-soft); }

.bar {
  height: 4px;
  background: var(--bg-soft);
  border-radius: 3px;
  margin: 12px 0 20px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), #8fb0ff);
  transition: width .25s ease;
}

.stem {
  font-size: 17px;
  line-height: 1.65;
  font-weight: 550;
  margin-bottom: 18px;
  white-space: pre-wrap;
}

.options { display: flex; flex-direction: column; gap: 9px; }

.opt {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
  user-select: none;
}
.opt:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand-soft) 70%, var(--bg-soft)); }
.opt:active { transform: scale(.995); }

.opt .letter {
  flex: none;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-soft);
}
.opt .otext { flex: 1; font-size: 14px; line-height: 1.55; color: var(--text); }

.opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.opt.selected .letter { background: var(--brand); border-color: var(--brand); color: #fff; }

.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }

.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }

.opt.disabled { cursor: default; }
.opt.disabled:hover { border-color: var(--line); background: var(--bg-soft); }
.opt.correct.disabled:hover { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong.disabled:hover { border-color: var(--bad); background: var(--bad-soft); }

/* ---------------- 判定反馈 ---------------- */

.feedback {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.feedback.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: var(--ok-soft); }
.feedback.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); }

.fb-head { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-head .tag { font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--card); color: var(--text-soft); border: 1px solid var(--line); }
.fb-answer { margin-top: 8px; font-size: 13.5px; color: var(--text); }
.fb-answer b { color: var(--brand-deep); }
.fb-exp { margin-top: 8px; font-size: 13px; line-height: 1.65; color: var(--text-soft); white-space: pre-wrap; }
.fb-exp.no-exp { color: var(--muted); font-style: italic; }

/* ---------------- 题卡底部 ---------------- */

.qfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.qlive { font-size: 12px; color: var(--muted); }
.actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.hint { font-size: 11.5px; color: var(--muted); }

/* ---------------- 成绩单 ---------------- */

.resultcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px;
  text-align: center;
}
.result-top h2 { margin: 0 0 4px; font-size: 20px; }
.result-top p { margin: 0; color: var(--muted); font-size: 13px; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 26px 0;
}
.metric {
  padding: 16px 10px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.metric b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric span { font-size: 12px; color: var(--muted); }
.metric.big { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.metric.big b { font-size: 34px; color: var(--brand-deep); }

.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------------- 错题集 ---------------- */

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-head h2 { margin: 0; }
.panel-head .muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.head-actions .mini { width: auto; margin: 0; padding: 8px 30px 8px 12px; font-size: 13px; }

.wrong-list { display: flex; flex-direction: column; gap: 12px; }

.wrong-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 14px 16px;
}
.wi-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.wi-count {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bad-soft);
  color: var(--bad);
  font-weight: 600;
  font-size: 11.5px;
}
.wi-stem { margin: 8px 0 6px; font-size: 14.5px; font-weight: 550; }
.wi-answer { font-size: 12.5px; color: var(--text-soft); }
.wi-exp { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.wi-actions { margin-top: 10px; display: flex; gap: 8px; }
.wi-actions button {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.wi-actions button:hover { border-color: var(--brand); color: var(--brand); }
.wi-actions button.danger:hover { border-color: var(--bad); color: var(--bad); }

/* ---------------- 导入 ---------------- */

.muted-line { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.muted-line b { color: var(--text); }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  background: var(--bg-soft);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dz-icon { font-size: 28px; margin-bottom: 6px; }
.link { color: var(--brand); cursor: pointer; font-weight: 600; }
.dropzone .muted-line { margin: 6px 0 0; }

.import-actions { display: flex; gap: 10px; justify-content: flex-end; margin: 14px 0 0; }

.preview {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
  background: var(--ok-soft);
  font-size: 13px;
}
.preview.err { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); background: var(--bad-soft); }
.preview .pv-title { font-weight: 650; margin-bottom: 6px; }
.preview .pv-row { color: var(--text-soft); font-size: 12.5px; }
.preview .pv-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.preview .pv-chips span {
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-soft);
}

.section-title { margin: 26px 0 12px; font-size: 14px; color: var(--text-soft); }

.imported-list { display: flex; flex-direction: column; gap: 8px; }
.imported-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 13px;
}
.imported-item .ii-name { font-weight: 550; }
.imported-item .ii-sub { color: var(--muted); font-size: 11.5px; }

/* ---------------- 文档视图 ---------------- */

.doc { max-width: 860px; }
.doc h2 { font-size: 19px; }
.doc h3 { margin: 22px 0 8px; font-size: 14.5px; color: var(--text); }
.doc ul { margin: 0; padding-left: 20px; color: var(--text-soft); font-size: 13.5px; }
.doc ul li { margin-bottom: 6px; }
.doc pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-soft);
}
.doc code {
  background: var(--bg-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(24, 32, 45, .92);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 960px) {
  #view-practice { grid-template-columns: 1fr; }
  .setup { position: static; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .chips { order: 3; width: 100%; }
  .wrap { padding: 12px 14px 40px; }
  .tabs { padding: 8px 14px 0; overflow-x: auto; }
  .qcard { padding: 16px 16px 14px; }
  .stem { font-size: 15.5px; }
  .hint { display: none; }
  .actions { width: 100%; justify-content: flex-end; }
}
