:root {
  --bg: #0d1020;
  --bg-soft: #141834;
  --card: #191d3a;
  --card-2: #1f2447;
  --text: #e9ebff;
  --muted: #9aa3ca;
  --border: #2a2f55;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --ok: #2bd67b;
  --warn: #ffb020;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px;
  --maxw: 1080px;
}

[data-theme="light"] {
  --bg: #f5f6fc;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-2: #f0f2fb;
  --text: #1a1d33;
  --muted: #5b6288;
  --border: #e2e5f2;
  --shadow: 0 10px 30px rgba(40, 50, 100, .10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border-bottom: 1px solid var(--border);
}
.top-inner { display: flex; align-items: center; gap: 14px; height: 62px; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; white-space: nowrap; }
.brand span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.top nav a {
  color: var(--muted); font-size: 14px; padding: 6px 12px; border-radius: 999px;
  white-space: nowrap;
}
.top nav a:hover { color: var(--text); background: var(--card-2); text-decoration: none; }
.icon-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px;
  display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--card-2); }

/* ---------- hero ---------- */
.hero { padding: 54px 0 30px; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 12px; line-height: 1.25; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { color: var(--muted); font-size: 17px; max-width: 720px; margin: 0 0 22px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.pill { font-size: 13px; color: var(--muted); border: 1px solid var(--border); background: var(--card); padding: 5px 12px; border-radius: 999px; }

/* progress */
.progress-card {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--card)), var(--card));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow);
}
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.progress-head b { font-size: 15px; }
.progress-head .pct { font-size: 24px; font-weight: 800; color: var(--accent-2); }
.bar { height: 10px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.progress-sub { color: var(--muted); font-size: 13px; margin-top: 8px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }

/* ---------- sections ---------- */
section { padding: 40px 0; }
.sec-title { font-size: 26px; margin: 0 0 6px; }
.sec-desc { color: var(--muted); margin: 0 0 24px; }

/* fork cards */
.fork { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fork .card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.fork .card h3 { margin: 0 0 8px; font-size: 18px; }
.fork .card ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.tagline { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; }
.tag-rec { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.tag-alt { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }

/* ---------- timeline ---------- */
.timeline { position: relative; }
.stage {
  position: relative; margin: 0 0 18px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.stage.done { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.stage-head {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px; cursor: pointer;
  user-select: none;
}
.stage-num {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.stage.done .stage-num { background: linear-gradient(135deg, var(--ok), #16a34a); }
.stage-title { flex: 1; min-width: 0; }
.stage-title h3 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stage-title .dur { font-size: 12px; color: var(--muted); font-weight: 500; border: 1px solid var(--border); padding: 1px 9px; border-radius: 999px; }
.stage-title .goal { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.stage-ring { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chev { flex: none; color: var(--muted); transition: transform .25s; }
.stage.open .chev { transform: rotate(180deg); }
.stage-body { display: none; padding: 0 20px 20px; border-top: 1px solid var(--border); }
.stage.open .stage-body { display: block; }
.stage-body h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 18px 0 10px; }

/* topics */
.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.topic { display: flex; align-items: flex-start; gap: 9px; padding: 5px 0; font-size: 14.5px; cursor: pointer; }
.topic input { margin-top: 5px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; cursor: pointer; }
.topic input:checked + span { color: var(--muted); text-decoration: line-through; }

/* resources */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.res {
  display: flex; gap: 12px; align-items: flex-start; background: var(--card-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.res .ic { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; background: var(--bg-soft); }
.res .meta { min-width: 0; }
.res .meta b { display: block; font-size: 14.5px; font-weight: 600; }
.res .meta small { color: var(--muted); font-size: 12.5px; display: block; line-height: 1.5; }
.res a.open { font-size: 12.5px; color: var(--accent-2); }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); margin-left: 6px; white-space: nowrap; display: inline-block; }
.badge.pdf { color: #ff6b81; border-color: color-mix(in srgb, #ff6b81 45%, var(--border)); }
.badge.video { color: #ffa94d; border-color: color-mix(in srgb, #ffa94d 45%, var(--border)); }
.badge.web { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 45%, var(--border)); }

/* filter */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filters button {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.filters button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }

/* table */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; }
tbody tr:hover { background: var(--card-2); }

/* glossary */
.search-box { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 15px; margin-bottom: 16px; }
.search-box:focus { outline: 2px solid var(--accent); border-color: transparent; }
.gloss { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gloss .g { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 15px; }
.gloss .g b { color: var(--accent-2); }
.gloss .g p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }

/* code */
pre { background: #0a0d1a; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; overflow-x: auto; position: relative; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 13.5px; }
p code, li code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; }
pre code { color: #a5d6ff; }
.copy-btn { position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; }

/* footer */
footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: 13.5px; }
footer a { color: var(--muted); }

.tip { background: color-mix(in srgb, var(--accent) 12%, var(--card)); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 16px; font-size: 14px; color: var(--text); margin: 14px 0; }
.tip b { color: var(--accent-2); }

@media (max-width: 720px) {
  .fork, .gloss, .topics { grid-template-columns: 1fr; }
  .top nav { display: none; }
  .hero { padding: 32px 0 20px; }
  .stage-head { padding: 15px; gap: 11px; }
  .stage-num { width: 38px; height: 38px; font-size: 16px; }
  .stage-body { padding: 0 15px 16px; }
}

/* ---------- 打卡 / 番茄钟 ---------- */
.checkin { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 4px; font-size: 17px; }
.panel .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.heat { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px; }
.heat .col { display: flex; flex-direction: column; gap: 4px; }
.heat .cell { width: 13px; height: 13px; border-radius: 3px; background: var(--bg-soft); border: 1px solid var(--border); flex: none; }
.heat .cell.on { background: linear-gradient(135deg, var(--ok), #16a34a); border-color: transparent; }
.heat .cell.today { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.streak { display: flex; gap: 22px; margin-top: 14px; flex-wrap: wrap; }
.streak b { font-size: 22px; color: var(--accent-2); }
.streak small { display: block; color: var(--muted); font-size: 12px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; padding: 9px 18px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; margin-top: 14px; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--border); padding: 8px 15px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.btn-ghost:hover { background: var(--border); }
.pomo-time { font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; text-align: center; margin: 8px 0 2px; }
.pomo-time.run { color: var(--accent-2); }
.pomo-btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.pomo-count { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 10px; }

/* ---------- 笔记 ---------- */
.note { margin-top: 4px; }
.note textarea { width: 100%; min-height: 92px; resize: vertical; background: var(--card-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; box-sizing: border-box; }
.note textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.note-bar { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.note-bar .saved { color: var(--ok); font-size: 12.5px; margin-left: auto; }

/* ---------- 收藏星标 ---------- */
.res { position: relative; }
.res .star { position: absolute; top: 8px; right: 10px; cursor: pointer; font-size: 16px; color: var(--muted); background: none; border: none; line-height: 1; padding: 2px; }
.res .star:hover { color: var(--warn); }
.res .star.on { color: var(--warn); }
.res .meta b { padding-right: 20px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.open { display: flex; }
.modal .box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; max-width: 580px; width: 100%; box-shadow: var(--shadow); max-height: 88vh; overflow: auto; }
.modal .box h3 { margin: 0 0 8px; }
.modal .box p.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.modal textarea { width: 100%; min-height: 130px; background: var(--card-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; box-sizing: border-box; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.ask-btn { font-size: 12.5px; color: var(--accent-2); background: none; border: none; cursor: pointer; padding: 0; }
.fav-list { display: grid; gap: 8px; }
@media (max-width: 720px) { .checkin { grid-template-columns: 1fr; } .pomo-time { font-size: 38px; } }
