:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #1b2330;
  --text-soft: #5a6678;
  --border: #e2e8f2;
  --accent: #326ce5;        /* Kubernetes blue */
  --accent-soft: #e7f0ff;
  --ok: #1f9d55;
  --warn: #d9822b;
  --danger: #d64545;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow: 0 2px 10px rgba(20, 35, 70, .08);
  --radius: 14px;
}
[data-theme="dark"] {
  --bg: #0c1018;
  --surface: #141b27;
  --surface-2: #1c2636;
  --text: #e6ecf5;
  --text-soft: #93a1b5;
  --border: #243044;
  --accent: #4c8dff;
  --accent-soft: #16233b;
  --code-bg: #060a12;
  --shadow: 0 2px 14px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 800; font-size: 17px; letter-spacing: .3px; }
.topbar .brand .dot { color: var(--accent); }
.topbar .spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.94); }

/* ---------- Layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--accent) 0%, #6f4cff 100%);
  color: #fff; border-radius: var(--radius); padding: 22px 20px; box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 6px; font-size: 24px; }
.hero p { margin: 0; opacity: .92; font-size: 14px; }
.hero .meta { margin-top: 12px; font-size: 12px; opacity: .85; display: flex; gap: 14px; flex-wrap: wrap; }
.hero .meta a { color: #fff; text-decoration: underline; }

/* ---------- Progress overview ---------- */
.progress-overview {
  display: flex; align-items: center; gap: 14px; margin: 18px 0 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.ring { --p: 0; width: 56px; height: 56px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center; }
.ring::after { content: ""; position: absolute; width: 44px; height: 44px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; font-weight: 700; font-size: 14px; }
.progress-overview .txt b { font-size: 18px; }
.progress-overview .txt small { color: var(--text-soft); }

/* ---------- Search ---------- */
.search-box { position: relative; margin: 14px 0; }
.search-box input {
  width: 100%; padding: 13px 14px 13px 42px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px;
}
.search-box .si { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: .5; }

/* ---------- Module ---------- */
.module { margin-top: 22px; }
.module h2 { font-size: 18px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.module .mdesc { color: var(--text-soft); font-size: 13px; margin: 0 0 12px; }
.module .mbar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin: 8px 0 14px; }
.module .mbar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }

/* ---------- Lesson card ---------- */
.lesson {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
}
.lesson:active { transform: scale(.99); }
.lesson .done { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: grid; place-items: center; font-size: 13px; color: #fff; }
.lesson.done-yes .done { background: var(--ok); border-color: var(--ok); }
.lesson .body { flex: 1; min-width: 0; }
.lesson .body .t { font-weight: 650; font-size: 15.5px; }
.lesson .body .s { color: var(--text-soft); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson .meta { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.min { background: var(--surface-2); color: var(--text-soft); }
.chip.lv-入门 { background: #e7f7ee; color: var(--ok); }
.chip.lv-进阶 { background: #fff2e3; color: var(--warn); }
[data-theme="dark"] .chip.lv-入门 { background: #10331f; color: #5fd99a; }
[data-theme="dark"] .chip.lv-进阶 { background: #33240f; color: #f0b366; }

/* ---------- Lesson reader ---------- */
.reader { max-width: 760px; margin: 0 auto; padding: 12px 16px 120px; }
.reader .crumbs { font-size: 13px; color: var(--text-soft); margin: 4px 0 10px; }
.reader h1 { font-size: 24px; margin: 6px 0 4px; }
.reader .ltags { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.reader .official { display: inline-flex; gap: 6px; align-items: center; margin: 10px 0; font-size: 13px; padding: 8px 12px; background: var(--accent-soft); border-radius: 10px; }
.reader .progress-line { height: 4px; background: var(--surface-2); border-radius: 4px; position: sticky; top: 62px; z-index: 20; overflow: hidden; }
.reader .progress-line i { display: block; height: 100%; background: var(--accent); width: 0; }

/* markdown */
.md h1, .md h2, .md h3, .md h4 { line-height: 1.35; margin: 1.4em 0 .6em; }
.md h2 { font-size: 20px; border-left: 4px solid var(--accent); padding-left: 10px; }
.md h3 { font-size: 17px; }
.md p { margin: .7em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: .6em 0; }
.md li { margin: .3em 0; }
.md blockquote { margin: 1em 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; color: var(--text-soft); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.md table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.md th { background: var(--surface-2); }
.md code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 13.5px; font-family: "SFMono-Regular", Consolas, monospace; }
.md pre.code { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: 12px; padding: 14px 14px 14px; overflow-x: auto; margin: 1em 0; }
.md pre.code code { background: none; padding: 0; color: inherit; font-size: 13px; line-height: 1.55; white-space: pre; }
.md pre.code .copy { position: absolute; top: 8px; right: 8px; font-size: 11px; padding: 4px 9px; border-radius: 7px; border: none; background: #233; color: #cdd; cursor: pointer; }
.md pre.code .copy:active { transform: scale(.95); }
.md pre.code[data-lang]::before { content: attr(data-lang); position: absolute; top: 8px; left: 12px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #5b6b86; }
.md pre.code[data-lang] { padding-top: 30px; }

/* reader bottom bar */
.reader-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--border);
}
.reader-bar button { flex: 1; padding: 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; }
.reader-bar button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.reader-bar button:active { transform: scale(.97); }
.reader-bar button.done-on { background: var(--ok); border-color: var(--ok); color: #fff; }

/* bottom nav (home) */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.bottom-nav a { flex: 1; text-align: center; color: var(--text-soft); font-size: 12px; padding: 6px 0; text-decoration: none; }
.bottom-nav a .ic { font-size: 20px; display: block; }
.bottom-nav a.active { color: var(--accent); }

/* ---------- Floating TOC button ---------- */
.fab {
  position: fixed; right: 16px; bottom: 150px; z-index: 45;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 20px; line-height: 1;
  box-shadow: var(--shadow); cursor: pointer; display: none; place-items: center;
}
.fab:active { transform: scale(.92); }

/* ---------- TOC drawer ---------- */
.toc-mask { position: fixed; inset: 0; background: rgba(10,16,28,.45); z-index: 50;
  opacity: 0; visibility: hidden; transition: opacity .2s; }
.toc-mask.show { opacity: 1; visibility: visible; }
.toc-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 80%; max-width: 320px; z-index: 51;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.toc-drawer.open { transform: translateX(0); }
.toc-head { display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.toc-close { border: none; background: none; color: var(--text-soft); font-size: 18px; cursor: pointer; }
.toc-list { padding: 10px 16px 24px; overflow-y: auto; }
.toc-item { display: block; padding: 10px 0; color: var(--text); text-decoration: none;
  border-bottom: 1px solid var(--border); font-size: 14px; }
.toc-item.toc-h3 { padding-left: 14px; font-size: 13px; color: var(--text-soft); }
.toc-item:active { color: var(--accent); }

/* misc */
.empty { text-align: center; color: var(--text-soft); padding: 40px 0; }
.tag-filter { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.tag-filter button { white-space: nowrap; font-size: 13px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); cursor: pointer; }
.tag-filter button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 首页刷题 CTA */
.quiz-cta { display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 14px 16px;
  background: linear-gradient(120deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); }
.quiz-cta:active { transform: scale(.99); }
.qc-ic { font-size: 26px; }
.qc-t { flex: 1; }
.qc-t b { display: block; font-size: 16px; }
.qc-t small { color: var(--text-soft); }
.qc-go { font-size: 22px; color: var(--accent); font-weight: 800; }
