:root {
  --bg: #f4f6fb;
  --bg-deep: #eaeef7;
  --surface: #ffffff;
  --surface-soft: #f8f9fd;
  --ink: #131a2b;
  --ink-soft: #39415a;
  --muted: #6d7691;
  --line: #e3e7f1;
  --line-strong: #d2d8e6;
  --accent: #2f5df0;
  --accent-soft: #e8eeff;
  --done: #10874b;
  --done-soft: #e5f6ec;
  --doing: #b67407;
  --doing-soft: #fdf1d9;
  --danger: #c63434;
  --shadow-sm: 0 1px 2px rgba(19, 26, 43, .06), 0 8px 24px -18px rgba(19, 26, 43, .35);
  --shadow-md: 0 1px 3px rgba(19, 26, 43, .07), 0 18px 40px -26px rgba(19, 26, 43, .32);
  --radius: 14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --bg-deep: #12161f;
    --surface: #161b26;
    --surface-soft: #1b2230;
    --ink: #eef1f8;
    --ink-soft: #c8cfe1;
    --muted: #8d97ae;
    --line: #262e3d;
    --line-strong: #333d4f;
    --accent: #7d9dff;
    --accent-soft: #1d2742;
    --done: #4ed08b;
    --done-soft: #16312536;
    --doing: #f0b95b;
    --doing-soft: #33270f;
    --danger: #ff8080;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 18px 40px -24px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font: inherit;
  color: inherit;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

.app-shell { min-height: 100vh; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--surface);
  cursor: pointer;
  transition: background .16s, border-color .16s, transform .12s, color .16s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 11px 26px;
  box-shadow: 0 10px 24px -12px var(--accent);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-quiet { background: transparent; border-color: var(--line-strong); color: var(--ink-soft); }
.btn-quiet:hover { background: var(--surface); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { color: var(--ink); }
.btn-danger-quiet { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-quiet:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.w100 { width: 100%; }

.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- 首次配置 ---------- */
.setup { min-height: 100vh; display: grid; place-items: center; padding: 48px 20px 40px; }
.setup-inner { width: 100%; max-width: 660px; }
.setup-head { margin-bottom: 22px; }
.brand-mark {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
  font-weight: 600;
}
.setup-head h1 { font-size: 30px; line-height: 1.25; }
.lede { color: var(--muted); margin: 10px 0 0; max-width: 54ch; }

.setup-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px;
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 18px;
}
.field { display: grid; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); letter-spacing: .01em; }
.field-hint { margin: 0; font-size: 12.5px; color: var(--muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 6px 15px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-soft);
  transition: all .15s;
}
.chip:hover { border-color: var(--muted); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip[disabled] { opacity: .45; cursor: not-allowed; }

.row-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.setup-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.who { min-width: 0; }
.who-title {
  font-weight: 650;
  font-size: 15.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; background: var(--bg-deep); padding: 4px; border-radius: 999px; }
.tab {
  border: 0;
  background: transparent;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: all .16s;
}
.tab.is-active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ---------- 布局 ---------- */
.content {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 22px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 22px;
  align-items: start;
}
.side { display: grid; gap: 14px; position: sticky; top: 74px; }
.pane { min-width: 0; }

/* ---------- 侧栏 ---------- */
.side-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.side-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.big-ring { position: relative; display: grid; place-items: center; padding: 4px 0 10px; }
.big-ring svg { width: 132px; height: 132px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset .7s cubic-bezier(.3, .9, .3, 1), stroke .3s;
}
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label span { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.ring-label small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 5px; letter-spacing: .02em; }

.side-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.stat { background: var(--surface-soft); border-radius: 10px; padding: 9px 11px; }
.stat b { display: block; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.stat span { font-size: 11.5px; color: var(--muted); }

.side-note { margin-top: 10px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.module-bars { display: grid; gap: 11px; max-height: 300px; overflow: auto; padding-right: 2px; }
.mbar { display: grid; gap: 5px; }
.mbar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.mbar-head b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbar-head span { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.mbar-track { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.mbar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s ease; }
.mbar-fill.is-full { background: var(--done); }

.side-tools { display: grid; gap: 6px; }
.side-tools .btn { font-size: 13px; padding: 8px 12px; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.search-wrap { position: relative; flex: 1 1 260px; min-width: 220px; }
.search-icon {
  position: absolute; left: 13px; top: 50%; width: 17px; height: 17px;
  transform: translateY(-50%); fill: var(--muted); pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 10px 38px 10px 38px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.search-input::-webkit-search-cancel-button { display: none; }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  width: 26px; height: 26px; border-radius: 50%;
}
.search-clear:hover { background: var(--bg-deep); color: var(--ink); }

.seg { display: flex; gap: 2px; background: var(--bg-deep); padding: 3px; border-radius: 999px; }
.seg button {
  border: 0; background: transparent; border-radius: 999px;
  padding: 7px 14px; font-size: 13px; color: var(--muted); cursor: pointer; transition: all .15s;
}
.seg button.is-active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

.search-summary { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

/* ---------- 培养方案 ---------- */
.plan-body { display: grid; gap: 12px; }

.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.group-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.group-head:hover { background: var(--surface-soft); }
.group-titles { min-width: 0; }
.group-crumb { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.group-name { font-size: 15.5px; font-weight: 650; margin-top: 2px; }
.group-meta { display: flex; align-items: center; gap: 8px; }
.chip-mini {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip-mini.is-req { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chip-mini.is-ok { background: var(--done-soft); color: var(--done); border-color: transparent; font-weight: 600; }
.group-progress { width: 54px; height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.group-progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.caret { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin: 0 4px 4px 8px; }
.group.is-open .caret { transform: rotate(-135deg); margin-bottom: 0; margin-top: 5px; }
.group-body { display: none; border-top: 1px solid var(--line); }
.group.is-open .group-body { display: block; }

.course {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  transition: background .15s;
}
.course:last-child { border-bottom: 0; }
.course:hover { background: var(--surface-soft); }
.course.is-done .c-name { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.course.is-doing .c-name { color: var(--doing); }

.check {
  appearance: none;
  width: 19px; height: 19px;
  border-radius: 6px;
  border: 1.6px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all .15s;
  margin: 0;
}
.check:hover { border-color: var(--accent); }
.check:checked { background: var(--done); border-color: var(--done); }
.check:checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px;
  width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(40deg);
}
.check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.c-main { min-width: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.c-name { font-size: 14.5px; font-weight: 550; }
.c-code { font-family: var(--mono); font-size: 11.5px; color: var(--muted); letter-spacing: -.02em; }
.c-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.c-tag.elective { border-style: dashed; }
.c-tag.track { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.c-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.c-credit { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.c-credit b { font-size: 14.5px; }
.c-term { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); white-space: nowrap; }
.term-hit { color: var(--accent); font-weight: 600; }
.doing-btn {
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: 999px;
  font-size: 11.5px;
  padding: 3px 10px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.doing-btn:hover { border-color: var(--doing); color: var(--doing); }
.doing-btn.is-on { border: 1px solid var(--doing); background: var(--doing-soft); color: var(--doing); font-weight: 600; }

.plan-note {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--muted);
}
.plan-note b { color: var(--ink-soft); font-weight: 600; }

/* ---------- 我的课程 ---------- */
.mine-head { margin: 0 0 16px; }
.mine-head h2 { font-size: 22px; }
.mine-sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
.mine-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.mine-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.mine-card-head { display: flex; align-items: center; gap: 9px; }
.mine-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.mine-dot.done { background: var(--done); }
.mine-dot.doing { background: var(--doing); }
.mine-dot.next { background: var(--accent); }
.mine-card h3 { font-size: 15px; }
.mine-card .mine-count { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mine-list { display: grid; gap: 2px; max-height: 420px; overflow: auto; margin: 0 -4px; }
.mine-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13.5px;
  align-items: center;
}
.mine-row:hover { background: var(--surface-soft); }
.mine-row .r-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine-row .r-side { display: flex; gap: 8px; align-items: center; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.mine-empty { font-size: 13px; color: var(--muted); padding: 8px; border: 1px dashed var(--line); border-radius: 9px; text-align: center; }
.badge-req { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge-opt { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--surface-soft); color: var(--muted); border: 1px dashed var(--line-strong); }
.mine-sum { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 9px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 50;
}
.toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .content { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; grid-template-columns: 1fr 1fr; display: grid; }
  .side-card:first-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: stretch; padding: 10px 14px; gap: 9px; }
  .topbar-left { justify-content: space-between; }
  .tabs { justify-content: space-between; }
  .tab { flex: 1; }
  .content { padding: 14px; gap: 14px; }
  .side { grid-template-columns: 1fr; }
  .side:has(.module-card) .module-card { display: none; }
  .setup-card { padding: 18px; }
  .setup-head h1 { font-size: 24px; }
  .course { grid-template-columns: 24px minmax(0, 1fr); }
  .course .c-right { grid-column: 2; justify-content: flex-start; }
  .group-head { grid-template-columns: 1fr auto; }
  .group-progress { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

[hidden] { display: none !important; }
