:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f6f6f4;
  --ink: #1a1a1a;
  --ink-muted: #5a5a5a;
  --ink-soft: #333333;
  --accent: #2a5d8a;
  --line: #e4e4e0;
  --line-strong: #c9c9c2;
  --max: 760px;
  --article: 680px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

img {
  display: block;
  max-width: 100%;
}

.home-shell,
.article-shell {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto;
}

.home-intro {
  padding: 56px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.home-intro h1 {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.home-intro p {
  max-width: 560px;
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.lede {
  max-width: 620px;
  margin: 14px 0 0;
  color: var(--ink-muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.post-list {
  padding: 16px 0 64px;
}

.section-rule {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.section-rule h2,
.related h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.section-rule a {
  font-size: 0.85rem;
  text-align: right;
}

.post-row {
  border-bottom: 1px solid var(--line);
}

.post-row a {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 6px 24px;
  padding: 18px 0;
  text-decoration: none;
  color: inherit;
}

.post-row time {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.post-row h3 {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
}

.post-row a:hover h3 {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.post-row p {
  grid-column: 2;
  max-width: 620px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.post-row .tags { grid-column: 2; }

.tags li {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.tags li::before {
  content: "#";
  color: var(--line-strong);
}

.empty-state {
  padding: 24px 0;
  color: var(--ink-muted);
}

.draft-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  margin: 16px auto 0;
  width: min(100%, var(--article));
  border-left: 3px solid var(--line-strong);
  padding: 8px 12px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.draft-banner strong {
  color: var(--ink);
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.brand {
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}

article {
  width: min(100%, var(--article));
  margin: 0 auto;
}

.article-header {
  padding: 48px 0 24px;
}

.article-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.25;
}

.article-header .tags {
  margin-top: 16px;
}

.featured-image {
  margin: 0 auto 32px;
}

.featured-image img {
  width: 100%;
  border: 1px solid var(--line);
}

.article-body {
  padding-bottom: 64px;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.7;
}

.article-body > * {
  margin-left: 0;
  margin-right: 0;
}

.article-body p,
.article-body ul,
.article-body ol,
.article-body blockquote,
.article-body pre {
  margin-top: 0;
  margin-bottom: 1.2em;
}

.article-body h2 {
  margin: 1.8em 0 0.5em;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
}

.article-body h3 {
  margin: 1.6em 0 0.5em;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4rem;
}

.article-body li + li {
  margin-top: 0.35em;
}

.article-body blockquote {
  border-left: 3px solid var(--line-strong);
  padding: 0 0 0 1rem;
  color: var(--ink-soft);
  font-style: italic;
}

.article-body code {
  border-radius: 3px;
  padding: 0.08rem 0.3rem;
  background: var(--bg-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
}

.article-body pre {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  background: var(--bg-soft);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

.article-body pre code {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.related {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px 24px;
  margin: 0 auto 64px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.related a {
  grid-column: 2;
}

@media (max-width: 640px) {
  .section-rule,
  .post-row a,
  .related {
    display: block;
  }

  .section-rule a {
    display: inline-block;
    margin-top: 8px;
    text-align: left;
  }

  .post-row time,
  .post-row p,
  .post-row .tags,
  .related a {
    display: block;
    margin-top: 8px;
  }
}

.theme-switcher {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 9999;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.7rem;
  color: #111;
  opacity: 0.45;
  transition: opacity 140ms ease;
}

.theme-switcher:hover,
.theme-switcher[open] { opacity: 1; }

.theme-switcher summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(8px);
}

.theme-switcher summary::-webkit-details-marker { display: none; }
.theme-switcher summary::marker { content: ""; }

.theme-switcher-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1a1a1a;
}

.theme-switcher-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 120px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 6px;
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
}

.theme-switcher-menu a {
  color: inherit;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 4px;
}

.theme-switcher-menu a:hover { background: rgba(0, 0, 0, 0.06); }

.theme-switcher-menu a[aria-current="true"] {
  background: #1a1a1a;
  color: #fff;
}
