:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --text-body: #334155;
  --muted: #475569;
  --border: #e2e8f0;
  --input-border: #cbd5e1;
  --th-bg: #f1f5f9;
  --accent: #2563eb;
  --be-bg: #dbeafe;
  --be-cell: #eff6ff;
  --be-text: #1e40af;
  --le-bg: #dcfce7;
  --le-cell: #f0fdf4;
  --le-text: #166534;
  --code-bg: #f1f5f9;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --text-body: #cbd5e1;
  --muted: #94a3b8;
  --border: #334155;
  --input-border: #475569;
  --th-bg: #0f172a;
  --accent: #60a5fa;
  --be-bg: #1e3a8a;
  --be-cell: rgba(30, 58, 138, 0.45);
  --be-text: #93c5fd;
  --le-bg: #14532d;
  --le-cell: rgba(20, 83, 45, 0.45);
  --le-text: #86efac;
  --code-bg: #0f172a;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  padding: 2rem 1rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.container { max-width: 820px; margin: 0 auto; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 1rem;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.025em;
}

.subtitle { color: var(--muted); font-size: 0.95rem; margin-top: 0.2rem; }

.theme-toggle {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.theme-toggle:hover { border-color: var(--accent); }

section, article.post {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

h1 { font-size: 2rem; line-height: 1.25; margin-bottom: 0.5rem; }
h2 { font-size: 1.35rem; margin: 1.5rem 0 0.75rem; }
p { margin-bottom: 1rem; color: var(--text-body); }
ul { padding-left: 1.25rem; margin-bottom: 1rem; color: var(--text-body); }
li { margin-bottom: 0.45rem; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-list { list-style: none; padding-left: 0; }
.post-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.post-item:last-child { border-bottom: none; padding-bottom: 0; }
.post-date { display: block; font-size: 0.85rem; color: var(--muted); }
.post-link { font-size: 1.25rem; font-weight: 700; color: var(--accent); text-decoration: none; }
.post-link:hover { text-decoration: underline; }
.post-summary { margin: 0.35rem 0 0; font-size: 0.95rem; }
.post-meta { font-size: 0.9rem; color: var(--muted); margin-bottom: 1.5rem; }
.post-nav { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.post-nav a { color: var(--accent); text-decoration: none; font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.card-box, .demo-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.badge-be { background: var(--be-bg); color: var(--be-text); }
.badge-le { background: var(--le-bg); color: var(--le-text); }

.demo-controls { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }

input[type="text"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1rem;
  padding: 0.45rem 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  width: 140px;
}

.mem-table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-align: center;
}

.mem-table th, .mem-table td { border: 1px solid var(--border); padding: 0.6rem; }
.mem-table th { background: var(--th-bg); font-size: 0.85rem; color: var(--muted); }
.msb { font-weight: 700; color: var(--be-text); background: var(--be-cell); }
.lsb { font-weight: 700; color: var(--le-text); background: var(--le-cell); }

footer { text-align: center; font-size: 0.875rem; color: var(--muted); margin-top: 2rem; }
