:root {
  --bg: #0b1220;
  --bg-soft: #121a2b;
  --panel: rgba(18, 28, 48, 0.88);
  --card: rgba(24, 36, 58, 0.92);
  --line: rgba(148, 163, 184, 0.18);
  --text: #e5eefc;
  --muted: #9fb0c9;
  --primary: #14b8a6;
  --primary-2: #2dd4bf;
  --accent: #60a5fa;
  --warn: #fbbf24;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --nav-w: 240px;
  --top-h: 74px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(20, 184, 166, 0.16), transparent 50%),
              radial-gradient(900px 500px at 100% 0%, rgba(96, 165, 250, 0.12), transparent 45%),
              var(--bg);
  min-height: 100vh;
  line-height: 1.65;
}

code, pre, .term, .cmd-chip, .brand-mark, .fab { font-family: var(--mono); }
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(148,163,184,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,0.05) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 85%);
}

.topbar, .sidenav, .content, .fab, .modal { position: relative; z-index: 1; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  background: rgba(11, 18, 32, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), #0f766e);
  color: white; font-weight: 700; box-shadow: 0 8px 24px rgba(20,184,166,.35);
}
.brand strong { display: block; font-size: 1.02rem; }
.brand p { margin: 0; color: var(--muted); font-size: 0.82rem; }

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.progress-chip {
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  font-size: 0.85rem;
}
.progress-bar {
  margin-top: 6px; height: 6px; border-radius: 999px; background: rgba(148,163,184,.15); overflow: hidden;
}
.progress-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: inherit; transition: width .25s ease;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
  color: var(--text);
  background: rgba(30, 41, 59, 0.8);
  transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), #0d9488);
  color: #042f2e; font-weight: 600;
  box-shadow: 0 8px 20px rgba(20,184,166,.25);
}
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.sidenav {
  position: fixed;
  top: var(--top-h);
  left: 0; bottom: 0;
  width: var(--nav-w);
  padding: 18px 12px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(10, 16, 28, 0.7);
  backdrop-filter: blur(10px);
}
.nav-label {
  margin: 0 10px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.nav-link {
  display: block;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}
.nav-link:hover, .nav-link.active {
  background: rgba(20, 184, 166, 0.12);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active { border: 1px solid rgba(20,184,166,.28); }

.content {
  margin-left: var(--nav-w);
  padding: 28px 28px 80px;
  max-width: 1100px;
}

.panel {
  margin-bottom: 34px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel-head .tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(96,165,250,.12);
  color: #93c5fd;
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.panel-head h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 2vw, 2rem); }
.lead { margin: 0; color: var(--muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.card {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
}
.card h3 { margin: 0 0 10px; font-size: 1.05rem; }
.card p:last-child, .card ul:last-child, .card pre:last-child { margin-bottom: 0; }

.checklist, .steps { padding-left: 1.15rem; margin: 0; }
.checklist li, .steps li { margin: 0.35rem 0; }
.kv { list-style: none; padding: 0; margin: 0; }
.kv li {
  display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px dashed rgba(148,163,184,.15);
}
.kv li:last-child { border-bottom: 0; }
.kv code { color: var(--primary-2); }

.code-block {
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #071018;
  border: 1px solid rgba(148,163,184,.12);
  overflow: auto;
  color: #d1fae5;
  font-size: 0.88rem;
  line-height: 1.55;
}
.prompt-demo { color: #bfdbfe; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid rgba(148,163,184,.12); vertical-align: top; }
th { color: #cbd5e1; font-weight: 600; }

.tip, .warn {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.tip { background: rgba(20,184,166,.08); }
.warn { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.25); color: #fde68a; }

.cmd-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.cmd-chip {
  border: 1px solid rgba(20,184,166,.35);
  background: rgba(15, 23, 42, 0.8);
  color: #99f6e4;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.86rem;
}
.cmd-chip:hover { background: rgba(20,184,166,.15); }

.muted { color: var(--muted); font-size: 0.9rem; }
.lesson-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed rgba(148,163,184,.18);
}
.mark-done {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); cursor: pointer; user-select: none;
}
.mark-done input { width: 16px; height: 16px; accent-color: var(--primary); }

.mini-term {
  margin-top: 12px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(148,163,184,.18);
  background: #050b12;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}
.mini-term.large { min-height: 340px; }
.term-titlebar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: #0b1624;
  border-bottom: 1px solid rgba(148,163,184,.12);
  color: var(--muted);
  font-size: 0.82rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.r { background: #fb7185; }
.dot.y { background: #fbbf24; }
.dot.g { background: #34d399; }
.term-screen {
  height: 240px;
  overflow: auto;
  padding: 12px 14px 8px;
  color: #dbeafe;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.mini-term.large .term-screen { height: 300px; }
.term-line.cmd { color: #a7f3d0; }
.term-line.out { color: #e2e8f0; }
.term-line.err { color: #fda4af; }
.term-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(148,163,184,.1);
  background: #071018;
}
.term-prompt { color: #5eead4; white-space: nowrap; font-size: 0.88rem; }
.term-input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: #f8fafc;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.practice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.practice-card {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  transition: .15s ease;
}
.practice-card:hover, .practice-card.active {
  border-color: rgba(20,184,166,.45);
  box-shadow: 0 0 0 1px rgba(20,184,166,.18);
}
.practice-card h3 { margin: 0 0 6px; font-size: 1rem; }
.practice-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.practice-card .status {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--warn);
}
.practice-card.done .status { color: var(--ok); }
.practice-term-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
}
.practice-term-head h3 { margin: 0; }

.search {
  width: 100%;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  font: inherit;
}
.search:focus { outline: 2px solid rgba(20,184,166,.35); border-color: transparent; }

.site-footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}
.site-footer p { margin: 4px 0; }

.fab {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 30;
  width: 54px; height: 54px;
  border-radius: 16px;
  border: 0;
  cursor: pointer;
  color: #042f2e;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  box-shadow: 0 12px 30px rgba(20,184,166,.35);
}

.modal {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(960px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #0b1220;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  margin-bottom: 10px;
}
.modal-head strong { display: block; }
.modal-head p { margin: 4px 0 0; }

@media (max-width: 960px) {
  .sidenav {
    position: sticky;
    top: var(--top-h);
    width: auto;
    height: auto;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
  }
  .nav-label { display: none; }
  .nav-link { white-space: nowrap; margin: 0; }
  .content { margin-left: 0; padding: 16px 14px 90px; }
  .panel { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
