/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fb;
  --bg-code: #f5f7fa;
  --text: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #8c959f;
  --border: #e6e8eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #e8f0fe;
  --sidebar-width: 280px;
  --header-height: 60px;
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono",
    Menlo, monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 0;
}

.sidebar-logo {
  padding: 0 24px 20px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.sidebar-nav { padding: 0 12px; }
.sidebar-nav .nav-group { margin-bottom: 20px; }
.sidebar-nav .nav-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 12px 6px;
}
.sidebar-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* ===== Header (mobile) ===== */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.topbar .menu-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}
.topbar .logo { font-weight: 700; font-size: 16px; }

/* ===== Main ===== */
.main {
  flex: 1;
  min-width: 0;
  padding: 40px 56px 80px;
  max-width: 920px;
}

.content h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.content h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 36px 0 16px;
}
.content h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 24px 0 12px;
}
.content p { margin-bottom: 16px; color: var(--text); }
.content ul, .content ol { margin: 0 0 16px 24px; }
.content li { margin-bottom: 8px; }
.content strong { font-weight: 600; }

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 14px;
}
.content th, .content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.content th {
  background: var(--bg-secondary);
  font-weight: 600;
}
.content tr:nth-child(even) td { background: #fcfcfd; }

/* Code blocks */
.content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 16px 0 20px;
  font-size: 13.5px;
  line-height: 1.6;
}
.content code {
  font-family: var(--font-mono);
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  border: 1px solid var(--border);
}
.content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Inline callout / alert */
.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0;
  font-size: 14px;
}
.callout.warn { border-color: #f59e0b; background: #fffbeb; }
.callout.danger { border-color: #ef4444; background: #fef2f2; }
.callout strong { display: block; margin-bottom: 4px; }

/* Card grid on home */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: block;
  color: var(--text);
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  text-decoration: none;
}
.card h3 { margin: 0 0 6px; font-size: 16px; color: var(--accent); }
.card p { margin: 0; font-size: 14px; color: var(--text-secondary); }

/* Pager */
.pager {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.pager a {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  display: inline-block;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .next { margin-left: auto; }

/* ===== Backdrop (mobile) ===== */
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; }
  .main { padding: 24px 20px 60px; max-width: 100%; }
  .backdrop.show { display: block; }
}
