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

:root {
  --bg: #f8f9fa;
  --panel-bg: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --accent: #0d6efd;
  --accent-hover: #0b5ed7;
  --danger: #dc3545;
  --success: #198754;
  --warning-bg: #fff3cd;
  --warning-border: #ffc107;
  --code-bg: #f1f3f5;
  --radius: 8px;
  --font-mono: 'Consolas', 'Courier New', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1d23;
    --panel-bg: #212529;
    --border: #373b3e;
    --text: #e9ecef;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --danger: #ef4444;
    --success: #22c55e;
    --warning-bg: #3d3520;
    --warning-border: #b8860b;
    --code-bg: #2d2d2f;
  }
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

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

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.top-nav .back { font-size: 0.9rem; }
.top-nav .home { font-weight: 600; }

h1 {
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
}
.page-subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.category-card {
  display: block;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.category-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-decoration: none;
}
.category-card h2 { font-size: 1.1rem; margin-bottom: 0.3rem; }
.category-card p { color: var(--text-muted); font-size: 0.85rem; }
.category-card .count {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--code-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

/* Article sections */
.article {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.article h2 {
  font-size: 1.2rem;
  margin-bottom: 0.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.article .article-title-en {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.article h3 {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
  color: var(--accent);
}
.article p { margin-bottom: 0.5rem; }
.article ul, .article ol { margin: 0.4rem 0 0.75rem 1.4rem; }
.article li { margin-bottom: 0.25rem; }

.example {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.example .zh {
  color: var(--text-muted);
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
}
.speak-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  line-height: 1;
}
.speak-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tip {
  background: var(--warning-bg);
  border-left: 4px solid var(--warning-border);
  border-radius: 0 6px 6px 0;
  padding: 0.6rem 0.9rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.tip strong { color: var(--warning-border); }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0 0.9rem;
  font-size: 0.9rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
}
th {
  background: var(--code-bg);
  font-weight: 600;
}
.vocab-word-cell {
  font-family: var(--font-mono);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--text-muted);
  margin-left: 0.4rem;
  vertical-align: middle;
}

@media (max-width: 700px) {
  body { padding: 0.75rem; }
  .example { flex-direction: column; align-items: flex-start; }
  .category-grid { grid-template-columns: 1fr; }
}
