:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1b2333;
  --ink2: #3d4759;
  --muted: #7a8399;
  --line: #e6e9f2;
  --line2: #f0f2f8;
  --brand: #4c6ef5;
  --brand-soft: #eef2ff;
  --accent: #ff922b;
  --accent-soft: #fff4e6;
  --ok: #12b886;
  --ok-soft: #e6fcf5;
  --err: #e03131;
  --err-soft: #fff0f0;
  --warn: #f59f00;
  --shadow: 0 1px 2px rgba(27, 35, 51, .04), 0 8px 24px rgba(27, 35, 51, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #12b886, #4c6ef5);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: -.5px;
}
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: -2px; }
.topbar .spacer { flex: 1; }

.layout { display: flex; align-items: flex-start; gap: 20px; padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }
.sidenav {
  width: 176px; flex: 0 0 176px; position: sticky; top: 78px;
  display: flex; flex-direction: column; gap: 4px;
}
.sidenav button {
  text-align: left; border: 0; background: transparent; padding: 10px 14px;
  border-radius: 10px; color: var(--ink2); font-weight: 500; display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s;
}
.sidenav button:hover { background: #eef1f8; }
.sidenav button.on { background: var(--brand); color: #fff; }
.sidenav .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; }
.sidenav button.on .dot { opacity: 1; }
main { flex: 1; min-width: 0; }

.view { display: none; animation: fade .25s ease; }
.view.on { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- generic ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card > h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.card > .desc { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
h2.page-title { margin: 0 0 2px; font-size: 20px; font-weight: 800; letter-spacing: -.2px; }
p.page-desc { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink2);
  padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 13px;
  transition: all .15s;
}
.btn:hover { border-color: #cdd4e5; background: #fafbff; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #4263e0; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #ffd7d7; background: var(--err-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f2f4fa; color: var(--ink2); border-radius: 999px;
  padding: 2px 10px; font-size: 12px; font-weight: 600; margin: 0 6px 6px 0;
}
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.tag.ok { background: var(--ok-soft); color: #0b8a66; }
.tag.warn { background: var(--accent-soft); color: #d97706; }
.word-chip {
  display: inline-flex; align-items: baseline; gap: 6px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 10px; margin: 0 6px 6px 0; font-size: 13px; cursor: pointer;
}
.word-chip:hover { border-color: var(--brand); background: var(--brand-soft); }
.word-chip > b { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-weight: 600; color: var(--ink); }
.word-chip > i { font-style: normal; color: var(--muted); font-size: 12px; }
.speak {
  border: 0; background: var(--brand-soft); color: var(--brand);
  width: 24px; height: 24px; border-radius: 7px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; margin-left: 4px; vertical-align: middle; cursor: pointer;
}
.speak:hover { background: #dfe5ff; }

/* 六维知识点：单词分组 / 词组 / 句型 */
.h4-line { display: flex; align-items: center; justify-content: space-between; }
.wgroup { margin: 4px 0 10px; }
.wgroup-cat { font-size: 12px; font-weight: 700; color: var(--brand); margin: 0 0 6px; }
.wgroup-words { display: flex; flex-wrap: wrap; }
.phrase-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.phrase { position: relative; background: #fafbff; border: 1px solid var(--line2); border-radius: 10px; padding: 8px 34px 8px 12px; }
.phrase .en { font-weight: 600; font-size: 13.5px; }
.phrase .zh { color: var(--muted); font-size: 12px; margin-top: 2px; }
.phrase .speak { position: absolute; right: 8px; top: 8px; margin: 0; }
.pattern { background: #fff; border: 1px solid var(--line2); border-left: 3px solid var(--brand); border-radius: 10px; padding: 9px 12px; margin-bottom: 7px; }
.pattern .pt-p { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.pattern .pt-eg { font-size: 13px; color: var(--ink2); margin-top: 3px; font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; }
.pattern .pt-zh { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bar { height: 8px; background: #eef0f7; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }

/* ---------- plan ---------- */
.plan-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.stat-mini { display: flex; flex-direction: column; }
.stat-mini b { font-size: 20px; font-weight: 800; line-height: 1.2; }
.stat-mini span { font-size: 12px; color: var(--muted); }

.stage-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.stage-tabs button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink2);
}
.stage-tabs button.on { color: #fff; border-color: transparent; }

.week {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden;
}
.week-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; }
.week-head:hover { background: #fafbff; }
.week-no {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; line-height: 1.1;
}
.week-no small { font-size: 9px; font-weight: 600; opacity: .85; }
.week-title { flex: 1; min-width: 0; }
.week-title b { display: block; font-size: 14.5px; }
.week-title span { font-size: 12px; color: var(--muted); }
.week-prog { width: 120px; flex: 0 0 120px; }
.week-prog .bar { margin-top: 4px; }
.week-prog em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.chev { color: var(--muted); transition: transform .2s; }
.week.open .chev { transform: rotate(90deg); }
.week-body { display: none; padding: 4px 18px 18px; border-top: 1px dashed var(--line); }
.week.open .week-body { display: block; }
.week-body h4 { margin: 16px 0 8px; font-size: 13px; font-weight: 700; color: var(--ink2); }
.week-body ul { margin: 0 0 4px; padding-left: 18px; }
.week-body li { margin-bottom: 4px; font-size: 13px; }
.sent { background: #fafbff; border: 1px solid var(--line2); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; font-size: 13px; }
.sent.en { font-weight: 600; }
.sent .cn { color: var(--muted); font-size: 12px; }
.sent .en { font-weight: 600; }
.sent-zh { color: var(--muted); font-size: 12px; margin-top: 3px; }

.task-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line2);
}
.task-item:last-child { border-bottom: 0; }
.task-item input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); flex: 0 0 16px; }
.task-item .tt { flex: 1; }
.task-item .tt b { font-weight: 600; font-size: 13.5px; }
.task-item .tt span { display: block; color: var(--muted); font-size: 12px; }
.task-item.done .tt b { color: var(--muted); text-decoration: line-through; }

/* ---------- checkin ---------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink2); margin-bottom: 6px; }
input[type=text], input[type=date], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(76, 110, 245, .13); }
textarea { resize: vertical; min-height: 60px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink2);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.soft.on { background: var(--brand-soft); border-color: #c7d2ff; color: var(--brand); }

.counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.counter {
  border: 1px solid var(--line); border-radius: 11px; padding: 10px; text-align: center; background: #fcfdff;
}
.counter label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.counter .ctl { display: flex; align-items: center; justify-content: center; gap: 8px; }
.counter button {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-weight: 700; line-height: 1; color: var(--ink2);
}
.counter button:hover { background: #f2f4fa; }
.counter .val { min-width: 54px; font-weight: 700; font-size: 14px; }
.counter .val em { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 500; }

.stars { display: flex; gap: 4px; }
.stars button { border: 0; background: transparent; font-size: 22px; line-height: 1; color: #dfe3ee; padding: 0 2px; }
.stars button.on { color: #ffb43a; }

.hm-wrap { overflow-x: auto; padding-bottom: 4px; }
.hm { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 3px; }
.hm i {
  width: 14px; height: 14px; border-radius: 3px; background: #eef0f7; display: block;
}
.hm i[data-l="1"] { background: #c3f3e2; }
.hm i[data-l="2"] { background: #7fe0bd; }
.hm i[data-l="3"] { background: #2fbf8f; }
.hm i[data-l="4"] { background: #128862; }
.hm i.today { outline: 2px solid var(--brand); outline-offset: 1px; }
.hm-legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.hm-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fcfdff; }
.kpi b { display: block; font-size: 24px; font-weight: 800; line-height: 1.2; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- quiz ---------- */
.q-card { max-width: 820px; }
.q-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.q-text { font-size: 17px; font-weight: 700; margin: 6px 0 16px; line-height: 1.5; }
.q-say { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand); border: 0; border-radius: 9px; padding: 5px 11px; font-size: 12.5px; font-weight: 700; margin-bottom: 12px; }
.opts { display: grid; gap: 9px; }
.opt {
  display: flex; align-items: flex-start; gap: 11px; text-align: left; width: 100%;
  border: 1.5px solid var(--line); background: #fff; border-radius: 11px; padding: 12px 14px;
  font-size: 14px; transition: all .13s;
}
.opt:hover:not(:disabled) { border-color: #b9c6f8; background: #fafbff; }
.opt .idx {
  flex: 0 0 24px; height: 24px; border-radius: 7px; background: #f2f4fa; color: var(--ink2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px;
}
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .idx { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--err); background: var(--err-soft); }
.opt.wrong .idx { background: var(--err); color: #fff; }
.opt.dim { opacity: .55; }
.fb { margin-top: 14px; border-radius: 11px; padding: 12px 14px; font-size: 13px; }
.fb.ok { background: var(--ok-soft); color: #0a7d5e; }
.fb.no { background: var(--err-soft); color: #b02020; }
.fb b { display: block; margin-bottom: 2px; }

.result-ring { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.wrong-item { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; margin-bottom: 9px; background: #fcfdff; }
.wrong-item .wq { font-weight: 700; margin-bottom: 6px; }
.wrong-item .wa { font-size: 13px; color: var(--err); }
.wrong-item .ra { font-size: 13px; color: var(--ok); font-weight: 600; }
.wrong-item .note { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line2); }
table.tbl th { font-size: 12px; color: var(--muted); font-weight: 700; }
table.tbl tbody tr:hover { background: #fafbff; }

/* ---------- stats ---------- */
.chart { width: 100%; height: 180px; }
.legend-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend-row i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; vertical-align: -1px; }

.mastery { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mastery .nm { width: 130px; flex: 0 0 130px; font-size: 12.5px; color: var(--ink2); }
.mastery .bar { flex: 1; }
.mastery .pc { width: 42px; text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------- guide ---------- */
.method {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fcfdff; height: 100%;
}
.method h4 { margin: 0 0 6px; font-size: 14px; }
.method p { margin: 0; font-size: 12.8px; color: var(--ink2); }
.method .src { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.faq details { border-bottom: 1px solid var(--line2); padding: 9px 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.faq p { margin: 8px 0 0; font-size: 13px; color: var(--ink2); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: #1b2333; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .layout { flex-direction: column; padding: 14px; }
  .sidenav { width: 100%; flex: none; position: static; flex-direction: row; overflow-x: auto; }
  .sidenav button { white-space: nowrap; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week-prog { display: none; }
}
