:root {
  color-scheme: light;
  --background: #ffffff;
  --text: #111111;
  --muted: #666666;
  --border: #e7e7e7;
  --link: #0645d8;
  --link-hover: #003399;
  --surface: #f8f8f8;
  --focus: #1a5cff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #050505;
  --text: #f4f4f4;
  --muted: #a8a8a8;
  --border: #262626;
  --link: #6ea2ff;
  --link-hover: #a8c6ff;
  --surface: #101010;
  --focus: #8ab4ff;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
}

a {
  color: var(--link);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

p,
ul,
ol {
  margin: 0 0 1.2rem;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: 0;
}

.site-shell {
  width: min(100% - 2rem, 760px);
  margin: 0 auto;
}

.site-header {
  padding: 1rem 0 2.75rem;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 1;
  transform: translateY(-200%);
  background: var(--background);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-nav {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.site-brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  color: var(--muted);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text);
}

.nav-links a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.22em;
}

.theme-toggle {
  min-height: 2.5rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}

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

.site-main {
  min-height: 58vh;
}

.site-footer {
  margin-top: 5rem;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer p {
  margin: 0;
}

.hero {
  padding: 1rem 0 3.5rem;
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero h1,
.page-heading h1,
.article-header h1 {
  font-size: clamp(2.2rem, 12vw, 4.4rem);
  font-weight: 750;
}

.lead {
  max-width: 42rem;
  margin-top: 1.25rem;
  color: var(--text);
  font-size: clamp(1.12rem, 4vw, 1.35rem);
  line-height: 1.5;
}

.profile-details {
  margin: 2rem 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.profile-details li {
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}

.profile-details li:last-child {
  border-bottom: 1px solid var(--border);
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
}

.link-row a {
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
}

.latest-section,
.page-heading {
  padding-top: 0.5rem;
}

.latest-section h2,
.page-heading h1 {
  margin-bottom: 1.25rem;
}

.latest-section h2 {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.page-description {
  color: var(--muted);
  font-size: 1.08rem;
}

.article-list {
  display: grid;
  gap: 2rem;
  margin: 2.5rem 0 0;
  padding: 0;
  list-style: none;
}

.article-preview {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.article-preview time,
.article-header time,
.view-counter {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.article-preview h2,
.article-preview h3 {
  margin-top: 0.45rem;
  font-size: clamp(1.35rem, 6vw, 2rem);
}

.article-preview h2 a,
.article-preview h3 a {
  color: var(--text);
  text-decoration: none;
}

.article-preview h2 a:hover,
.article-preview h3 a:hover {
  color: var(--link);
  text-decoration: underline;
}

.article-preview p {
  margin-top: 0.75rem;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  margin: 0.9rem 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
}

.tag-list li::before {
  content: "#";
}

.article-detail,
.page-detail {
  padding-top: 0.5rem;
}

.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  max-width: 100%;
  font-size: clamp(2rem, 8vw, 3.6rem);
}

.article-header time {
  margin-top: 1rem;
}

.view-counter {
  margin: 1rem 0 0;
}

.prose {
  font-size: 1.05rem;
  line-height: 1.75;
}

.prose > * + * {
  margin-top: 1.2rem;
}

.prose h2,
.prose h3 {
  margin-top: 2.4rem;
}

.prose h2 {
  font-size: 1.65rem;
}

.prose h3 {
  font-size: 1.28rem;
}

.prose p,
.prose li {
  color: var(--text);
}

.prose code {
  padding: 0.12rem 0.25rem;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.92em;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.prose pre code {
  padding: 0;
  background: transparent;
}

.prose blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  color: var(--muted);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--surface);
  font-weight: 650;
}

.prose .callout {
  margin: 1.6rem 0;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--link);
  background: var(--surface);
}

.prose .callout strong {
  display: block;
  margin-bottom: 0.35rem;
}

.agent-loop,
.agent-flow {
  margin: 1.8rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.agent-loop {
  display: grid;
  gap: 0.55rem;
  justify-items: center;
  text-align: center;
  font-size: 0.95rem;
}

.agent-loop div,
.flow-node,
.flow-decision,
.flow-split > div {
  width: min(100%, 28rem);
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  background: var(--background);
}

.agent-loop span,
.flow-arrow {
  color: var(--muted);
  line-height: 1;
}

.agent-flow {
  display: grid;
  gap: 0.55rem;
  justify-items: center;
  text-align: center;
  font-size: 0.95rem;
}

.flow-decision {
  border-color: var(--link);
}

.flow-split {
  width: min(100%, 32rem);
  display: grid;
  gap: 0.65rem;
}

.flow-split span,
.flow-split strong {
  display: block;
}

.flow-split span {
  color: var(--muted);
  font-size: 0.85rem;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.empty-state {
  margin-top: 2.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.empty-state p,
.muted {
  color: var(--muted);
}

@media (min-width: 700px) {
  .site-shell {
    width: min(100% - 4rem, 820px);
  }

  .site-header {
    padding-top: 1.5rem;
  }

  .site-nav {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .nav-actions {
    justify-content: flex-end;
  }

  .hero {
    padding-top: 2rem;
  }

  .flow-split {
    grid-template-columns: 1fr 1fr;
  }
}
