:root {
  --bg: #101114;
  --surface: #17191f;
  --surface-2: #1f222b;
  --text: #e7e9ee;
  --muted: #a5adba;
  --subtle: #7d8594;
  --line: #2b303a;
  --accent: #7cc7ff;
  --accent-2: #fdc500;
  --code-bg: #0b0d12;
  --code-inline: #f6d365;
  --body-bg:
    radial-gradient(circle at top left, rgba(124, 199, 255, 0.12), transparent 24rem),
    linear-gradient(180deg, #101114 0%, #12151a 100%);
  --chrome-bg: #101114;
  --chrome-bg-translucent: rgba(16, 17, 20, 0.86);
  --chrome-surface: #17191f;
  --chrome-surface-2: #1f222b;
  --chrome-text: #e7e9ee;
  --chrome-muted: #a5adba;
  --chrome-subtle: #7d8594;
  --chrome-line: #2b303a;
  --max: 72rem;
  --measure: 44rem;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #171a21;
  --muted: #4f5969;
  --subtle: #6f7887;
  --line: #d8dde6;
  --accent: #006fbf;
  --accent-2: #794feb;
  --code-bg: #f0f3f8;
  --code-inline: #9a4d00;
  --body-bg:
    radial-gradient(circle at top left, rgba(0, 111, 191, 0.10), transparent 24rem),
    linear-gradient(180deg, #f7f8fb 0%, #eef1f6 100%);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  font-size: 16px;
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--chrome-bg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100%;
  line-height: 1.65;
  overflow: hidden;
}

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

a:hover {
  color: var(--accent-2);
}

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

.site-header {
  border-bottom: 1px solid var(--chrome-line);
  background: var(--chrome-bg-translucent);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner,
.site-footer {
  width: min(var(--max), calc(100% - 2rem));
  margin-inline: auto;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  min-height: 4.25rem;
}

.brand {
  color: var(--chrome-text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  min-width: 0;
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem 0.75rem;
  margin-left: auto;
}

.nav a {
  color: var(--chrome-muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.nav a:hover {
  color: var(--chrome-text);
}

.icon-sprite {
  display: none;
}

.theme-dropdown {
  flex: 0 0 auto;
  position: relative;
}

.theme-dropdown__toggle {
  align-items: center;
  background: var(--chrome-surface);
  border: 1px solid var(--chrome-line);
  border-radius: 0.35rem;
  color: var(--chrome-text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 0.35rem;
  min-height: 2.1rem;
  padding: 0.35rem 0.55rem;
}

.theme-dropdown__toggle:hover,
.theme-dropdown__toggle[aria-expanded="true"] {
  border-color: #7cc7ff;
}

.theme-dropdown__toggle::after {
  border-left: 0.28rem solid transparent;
  border-right: 0.28rem solid transparent;
  border-top: 0.32rem solid currentColor;
  content: "";
  margin-left: 0.1rem;
}

.theme-dropdown__icon {
  fill: currentColor;
  flex: 0 0 auto;
  height: 1rem;
  width: 1rem;
}

.theme-dropdown__label {
  display: none;
}

.theme-dropdown__menu {
  background: var(--chrome-surface);
  border: 1px solid var(--chrome-line);
  border-radius: 0.45rem;
  box-shadow: 0 0.85rem 2rem rgba(0, 0, 0, 0.28);
  display: none;
  list-style: none;
  margin: 0.35rem 0 0;
  min-width: 9rem;
  padding: 0.35rem;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
}

.theme-dropdown.open .theme-dropdown__menu {
  display: block;
}

.theme-dropdown__item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0.3rem;
  color: var(--chrome-muted);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  text-align: left;
  width: 100%;
}

.theme-dropdown__item:hover,
.theme-dropdown__item.active {
  background: var(--chrome-surface-2);
  color: var(--chrome-text);
}

.theme-dropdown__item-icon {
  opacity: 0.65;
}

.theme-dropdown__check {
  display: none;
  margin-left: auto;
}

.theme-dropdown__item.active .theme-dropdown__check {
  display: block;
}

.main {
  background: var(--body-bg);
  margin: 0;
  overflow-y: auto;
  padding-inline: max(1rem, calc((100% - var(--max)) / 2));
  padding-block: 3rem 4rem;
  width: 100%;
}

.hero {
  display: grid;
  gap: 1rem;
  max-width: var(--measure);
  margin-bottom: 2rem;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.2;
  margin: 2rem 0 0.75rem;
}

h1 {
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  letter-spacing: 0;
  margin-top: 0;
}

h2 {
  font-size: 1.65rem;
}

h3 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 1.15rem;
}

.lead {
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.7;
}

.latest-posts {
  max-width: var(--measure);
}

.post-list {
  display: grid;
  gap: 1.15rem;
  max-width: var(--measure);
}

.post-card {
  border-top: 1px solid var(--line);
  padding-top: 1.15rem;
}

.post-card h2 {
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
}

.post-card h2 a {
  color: var(--text);
  text-decoration: none;
}

.post-card h2 a:hover {
  color: var(--accent);
}

.meta {
  color: var(--subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.92rem;
  margin-bottom: 0.55rem;
}

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

.more-link {
  border-top: 1px solid var(--line);
  margin-top: 1.15rem;
  padding-top: 1rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.84rem;
  line-height: 1;
  padding: 0.42rem 0.62rem;
  text-decoration: none;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--text);
}

.article {
  margin-inline: auto;
  max-width: var(--measure);
}

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

.content {
  color: var(--text);
}

.content > * + * {
  margin-top: 1rem;
}

.content p,
.content li,
.content td,
.content th {
  color: var(--text);
}

.content h2,
.content h3,
.content h4 {
  scroll-margin-top: 2rem;
}

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

.content li + li {
  margin-top: 0.3rem;
}

.content blockquote {
  border-left: 3px solid var(--accent);
  color: var(--muted);
  margin: 1.5rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
}

.content blockquote p {
  color: var(--muted);
}

.content table {
  border-collapse: collapse;
  display: block;
  margin: 1.5rem 0;
  overflow-x: auto;
  width: 100%;
}

.content th,
.content td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  text-align: left;
}

.content th {
  background: var(--surface-2);
}

.content :not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  color: var(--code-inline);
  font-size: 0.92em;
  padding: 0.08rem 0.25rem;
}

.content pre,
.highlight pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  overflow-x: auto;
  padding: 2rem 1rem 1rem;
}

.highlight {
  position: relative;
}

.code-language {
  color: var(--subtle);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  position: absolute;
  left: 1rem;
  text-transform: lowercase;
  top: 0.75rem;
  z-index: 2;
}

.copy-code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
  padding: 0.38rem 0.5rem;
  position: absolute;
  right: 0.7rem;
  top: 0.7rem;
  z-index: 2;
}

.copy-code:hover {
  border-color: var(--accent);
  color: var(--text);
}

.content pre code,
.highlight code {
  font-size: 0.92rem;
}

.arithmatex .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 0.25rem;
}

.content img {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  list-style: none;
  margin: 1.5rem 0 0;
  max-width: var(--measure);
  padding: 0;
}

.terms a {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  display: inline-flex;
  gap: 0.45rem;
  padding: 0.7rem 0.85rem;
  text-decoration: none;
}

.terms span {
  color: var(--subtle);
}

.site-footer {
  background: var(--chrome-bg);
  border-top: 1px solid var(--chrome-line);
  color: var(--chrome-subtle);
  font-size: 0.92rem;
  margin: 0;
  padding-inline: max(1rem, calc((100% - var(--max)) / 2));
  padding-block: 1rem;
  width: 100%;
}

.site-footer a {
  color: var(--chrome-muted);
}

.site-footer a:hover {
  color: var(--chrome-text);
}

@media (max-width: 44rem) {
  .site-header__inner,
  .site-footer {
    width: min(var(--max), calc(100% - 1.5rem));
  }

  .site-header__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 0;
    padding-block: 0.75rem;
  }

  .brand {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-left: 0;
    order: 3;
    overflow-x: auto;
    padding-bottom: 0.1rem;
    scrollbar-width: none;
    white-space: nowrap;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    flex: 0 0 auto;
    font-size: 0.92rem;
  }

  .theme-dropdown {
    justify-self: end;
  }

  .theme-dropdown__menu {
    max-width: calc(100vw - 1.5rem);
    right: 0;
  }

  .main {
    padding-block: 1.75rem 2.5rem;
    padding-inline: 0.75rem;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 2.45rem);
  }

  h2 {
    font-size: 1.45rem;
  }

  .lead {
    font-size: 1.05rem;
  }

  .hero {
    gap: 0.8rem;
    margin-bottom: 1.6rem;
  }

  .post-list {
    gap: 0.9rem;
  }

  .post-card {
    padding-top: 0.9rem;
  }

  .post-card h2 {
    font-size: 1.18rem;
  }

  .article-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.2rem;
  }

  .content pre,
  .highlight pre {
    padding: 2rem 0.85rem 0.85rem;
  }

  .copy-code {
    right: 0.55rem;
    top: 0.55rem;
  }
}
