:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #6b7280;
  --link: #1f2328;
  --accent: #2563eb;
  --border: #e5e7eb;
  --code-bg: #f3f4f6;
  --tok-comment: #6a737d;
  --tok-keyword: #cf222e;
  --tok-string: #0a3069;
  --tok-number: #0550ae;
  --tok-function: #8250df;
  --tok-builtin: #953800;
  --tok-punct: #57606a;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121212;
  --fg: #e6e6e6;
  --muted: #9a9a9a;
  --link: #e6e6e6;
  --accent: #7aa2f7;
  --border: #2a2a2a;
  --code-bg: #1e1e1e;
  --tok-comment: #8b949e;
  --tok-keyword: #ff7b72;
  --tok-string: #a5d6ff;
  --tok-number: #79c0ff;
  --tok-function: #d2a8ff;
  --tok-builtin: #ffa657;
  --tok-punct: #9da5ae;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0 auto;
  max-width: 960px;
  padding: 0 16px;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--link); text-decoration-color: var(--border); text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }

.muted { color: var(--muted); }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.site-title { font-weight: 700; font-size: 1.15rem; text-decoration: none; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 6px 9px;
}
.theme-toggle:hover { border-color: var(--muted); }
:root[data-theme="dark"] .icon-dark,
:root:not([data-theme="dark"]) .icon-light { display: none; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 48px;
}
.content { min-width: 0; }

@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .archive { border-top: 1px solid var(--border); padding-top: 24px; }
}

/* Search */
.search {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 24px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.search:focus { outline: none; border-color: var(--accent); }

/* Post list */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
}
.post-list time {
  flex: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.post-list .sep { flex: none; color: var(--muted); }
.post-list a { text-decoration: none; font-size: 1.08rem; }
.post-list a:hover { text-decoration: underline; }

/* Archive sidebar */
.archive { font-size: 0.9rem; }
.archive h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
}
.archive details { margin-bottom: 10px; }
.archive summary { cursor: pointer; font-weight: 600; }
.archive .count { color: var(--muted); font-weight: 400; font-size: 0.8rem; margin-left: 4px; }
.archive .month { color: var(--muted); margin: 8px 0 2px 14px; }
.archive ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.archive li { padding: 2px 0; line-height: 1.4; }
.archive a { text-decoration: none; color: var(--fg); }
.archive a:hover { color: var(--accent); }
.archive a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Post */
.post-title { font-size: 1.9rem; line-height: 1.25; margin: 0 0 6px; }
.post-date { color: var(--muted); font-size: 0.9rem; }
.post-body { margin-top: 28px; }
.post-body a { color: var(--accent); text-decoration-color: currentColor; }
.post-body a:hover { text-decoration-thickness: 2px; }
.post-body img { max-width: 100%; height: auto; }
.post-body h2, .post-body h3 { line-height: 1.3; margin-top: 2em; }
.post-body blockquote {
  margin: 1.5em 0;
  padding: 0 0 0 16px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }
code { background: var(--code-bg); padding: 2px 5px; border-radius: 4px; }
pre { background: var(--code-bg); padding: 14px 16px; border-radius: 6px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; }

/* Syntax highlighting (Prism tokens) */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--tok-comment); font-style: italic; }
.token.keyword, .token.statement, .token.selector, .token.important, .token.atrule,
.token.adverb, .token.conjunction, .token.monadic-operator, .token.dyadic-operator { color: var(--tok-keyword); }
.token.string, .token.char, .token.attr-value, .token.regex, .token.url { color: var(--tok-string); }
.token.number, .token.boolean, .token.constant, .token.symbol { color: var(--tok-number); }
.token.function, .token.verb, .token.class-name, .token.dfn { color: var(--tok-function); }
.token.builtin, .token.system-function, .token.variable, .token.property,
.token.attr-name, .token.tag, .token.section { color: var(--tok-builtin); }
.token.operator, .token.assignment, .token.entity { color: var(--tok-keyword); }
.token.punctuation { color: var(--tok-punct); }
.token.bold, .token.important { font-weight: 600; }
table { border-collapse: collapse; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--border); padding: 6px 10px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

.back { margin-top: 48px; font-size: 0.95rem; }

/* Footer */
.site-footer {
  margin-top: 64px;
  padding: 20px 0 40px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer a { color: var(--muted); }

.post-source {
  margin-top: 40px;
  font-size: 0.9rem;
  color: var(--muted);
}
.post-source a { color: var(--muted); }
