* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- Theme variables ---- */
:root {
  --bg: #fff;
  --text: #24292e;
  --text-secondary: #586069;
  --border: #e1e4e8;
  --sidebar-bg: #f6f8fa;
  --sidebar-hover: #e1e4e8;
  --link: #0366d6;
  --blockquote-bg: #f6f8fa;
  --blockquote-border: #dfe2e5;
  --notice-bg: #fffbdd;
  --notice-border: #e8d44d;
  --tag-bg: #f1f8ff;
  --table-header-bg: #f6f8fa;
  --code-bg: #f6f8fa;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --text: #c9d1d9;
  --text-secondary: #8b949e;
  --border: #30363d;
  --sidebar-bg: #161b22;
  --sidebar-hover: #30363d;
  --link: #58a6ff;
  --blockquote-bg: #161b22;
  --blockquote-border: #30363d;
  --notice-bg: #1c1d00;
  --notice-border: #6e6811;
  --tag-bg: #0d2039;
  --table-header-bg: #161b22;
  --code-bg: #161b22;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* ---- Site header ---- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.2rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header h1 { font-size: 1.6rem; }
.site-header h1 a { color: var(--text); text-decoration: none; }
.site-header p.desc { color: var(--text-secondary); margin-top: 0.2rem; font-size: 0.95rem; }
.header-left { display: flex; flex-direction: column; }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1;
}
.theme-toggle:hover { background: var(--sidebar-hover); }

/* ---- Layout ---- */
.layout {
  display: flex;
  min-height: calc(100vh - 120px);
}

/* ---- Sidebar ---- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.2rem;
  background: var(--sidebar-bg);
}
.sidebar h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
}
.sidebar h3:first-child { margin-top: 0; }
.sidebar ul { list-style: none; padding: 0; }
.sidebar ul li { margin: 0.2rem 0; }
.sidebar ul li a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.sidebar ul li a:hover {
  background: var(--sidebar-hover);
  color: var(--link);
}

/* ---- Main content ---- */
.content {
  flex: 1;
  padding: 2rem 2.5rem;
  min-width: 0;
  max-width: 860px;
}

/* ---- Typography ---- */
h1 { font-size: 1.5rem; margin: 1.8rem 0 0.8rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.6rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
h3 { font-size: 1.1rem; margin: 1.2rem 0 0.5rem; }

p { margin: 0.6rem 0; }
a { color: var(--link); }

ul, ol { padding-left: 1.8rem; margin: 0.5rem 0; }
li { margin: 0.25rem 0; }

blockquote {
  border-left: 4px solid var(--blockquote-border);
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  margin: 1rem 0;
  background: var(--blockquote-bg);
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.92rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
  text-align: left;
}
th { background: var(--table-header-bg); font-weight: 600; }

img { max-width: 100%; height: auto; margin: 1rem 0; border-radius: 4px; }

code {
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.post-meta { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; }
.post-tags span {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--link);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.82rem;
  margin-right: 0.4rem;
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
}
.notice a { font-weight: 500; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
}

/* ---- Mobile responsive ---- */
@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0 2rem;
  }
  .sidebar h3 { margin-top: 0.5rem; width: 100%; }
  .sidebar ul { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; }
  .content { padding: 1.5rem; }
}
