:root {
  color-scheme: light;
  --paper: #e9eef2;
  --surface: #f8fafb;
  --ink: #101a26;
  --muted: #5f6c7b;
  --line: #c4ced7;
  --line-strong: #8d9aaa;
  --signal: #ee5b3e;
  --blue: #245b96;
  --code: #131c27;
  --code-ink: #dfe8ef;
  --shadow: rgba(16, 26, 38, 0.12);
  --display: "Arial Narrow", "Aptos Display", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --body: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #101721;
  --surface: #17212d;
  --ink: #edf3f7;
  --muted: #9ba9b8;
  --line: #2e3b49;
  --line-strong: #586779;
  --signal: #ff7659;
  --blue: #70a8df;
  --code: #0b1119;
  --code-ink: #e8f0f4;
  --shadow: rgba(0, 0, 0, 0.28);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 4px;
}

::selection {
  color: var(--surface);
  background: var(--blue);
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 20;
  padding: 0.6rem 0.9rem;
  color: var(--surface);
  background: var(--ink);
  transform: translateY(-180%);
}

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

.site-header,
.site-footer,
main {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 104px;
  border-bottom: 1px solid var(--line-strong);
}

.brand {
  display: inline-flex;
  gap: 0.85rem;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink);
  place-items: center;
  transform: rotate(45deg);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  position: absolute;
  content: "";
  background: var(--ink);
}

.brand-mark::before {
  width: 1px;
  height: 54px;
}

.brand-mark::after {
  width: 54px;
  height: 1px;
}

.brand-mark span {
  width: 7px;
  height: 7px;
  background: var(--signal);
  border-radius: 50%;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-copy strong {
  font-family: var(--display);
  font-size: 1.15rem;
  font-stretch: condensed;
  letter-spacing: 0.04em;
}

.brand-copy small,
.eyebrow,
.instrument-label,
.article-route,
.article-meta,
.signal-meta,
.article-rail small {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand-copy small {
  margin-top: 0.35rem;
  color: var(--muted);
}

.header-actions,
.site-nav {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 1.5rem;
}

.site-nav {
  gap: 1.6rem;
}

.site-nav a {
  position: relative;
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.site-nav a[aria-current="page"]::after {
  position: absolute;
  right: 0;
  bottom: -0.65rem;
  left: 0;
  height: 2px;
  content: "";
  background: var(--signal);
}

.theme-toggle {
  position: relative;
  width: 46px;
  height: 26px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  background: var(--ink);
  border-radius: 50%;
  transition: transform 180ms ease, background-color 180ms ease;
}

.theme-toggle[aria-pressed="true"] span {
  background: var(--signal);
  transform: translateX(20px);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: clamp(3rem, 8vw, 8rem);
  align-items: center;
  min-height: 610px;
  padding: 7rem 0 6rem;
  border-bottom: 1px solid var(--line-strong);
}

.eyebrow {
  margin: 0 0 1.35rem;
  color: var(--blue);
  font-weight: 700;
}

.home-hero h1,
.listing-header h1,
.article-header h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 760;
  font-stretch: condensed;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.home-hero h1 {
  max-width: 760px;
  font-size: clamp(4rem, 8vw, 7.8rem);
}

.home-hero h1 em {
  color: var(--signal);
  font-style: normal;
}

.hero-intro {
  max-width: 520px;
  margin: 2rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
}

.hero-instrument {
  position: relative;
  justify-self: end;
  width: min(100%, 360px);
  aspect-ratio: 1;
}

.instrument-label {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--muted);
}

.hero-instrument svg {
  width: 100%;
  overflow: visible;
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
}

.hero-instrument .signal-path {
  stroke: var(--blue);
  stroke-width: 2;
  stroke-linecap: round;
}

.hero-instrument .signal-pulse {
  fill: var(--signal);
  stroke: var(--paper);
  stroke-width: 5;
  transform-origin: 200px 110px;
  animation: signal-pulse 2.8s ease-out infinite;
}

@keyframes signal-pulse {
  0%, 40% { transform: scale(1); opacity: 1; }
  72% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

.feed-section,
.listing-page {
  padding: 6rem 0 7rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 3.5rem;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.2rem, 4vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.text-link {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.signal-list {
  position: relative;
}

.signal-list::before {
  position: absolute;
  top: 0.75rem;
  bottom: 0;
  left: 194px;
  width: 1px;
  content: "";
  background: var(--line-strong);
}

.signal-entry {
  position: relative;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 56px;
  padding: 0 0 4.5rem;
}

.signal-entry:last-child {
  padding-bottom: 0;
}

.signal-node {
  position: absolute;
  top: 0.54rem;
  left: 188px;
  z-index: 1;
  width: 13px;
  height: 13px;
  background: var(--paper);
  border: 3px solid var(--signal);
  border-radius: 50%;
  box-shadow: 0 0 0 5px var(--paper);
}

.signal-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  text-align: right;
}

.signal-meta a {
  color: var(--blue);
  text-decoration: none;
}

.signal-body {
  max-width: 760px;
}

.signal-body h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.signal-body h2 a {
  text-decoration: none;
}

.signal-body p {
  max-width: 680px;
  margin: 1rem 0 0;
  color: var(--muted);
}

.live-preview {
  position: relative;
  display: block;
  max-width: 760px;
  margin-top: 1.4rem;
  overflow: hidden;
  background: var(--code);
  border: 1px solid var(--line-strong);
  box-shadow: 7px 7px 0 var(--line);
}

.live-preview img {
  display: block;
  width: 100%;
  min-height: 180px;
  max-height: 440px;
  object-fit: cover;
}

.live-badge {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  z-index: 1;
  display: inline-flex;
  gap: 0.42rem;
  align-items: center;
  padding: 0.3rem 0.5rem;
  color: #fff;
  background: rgba(16, 26, 38, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
}

.live-badge i {
  width: 7px;
  height: 7px;
  background: var(--signal);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(238, 91, 62, 0.2);
}

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

.tag-list a {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.76rem;
  text-decoration: none;
}

.listing-header {
  max-width: 780px;
  padding-bottom: 4rem;
}

.listing-header h1,
.article-header h1 {
  font-size: clamp(3.4rem, 7vw, 6.8rem);
}

.listing-header > p:last-child {
  color: var(--muted);
  font-size: 1.08rem;
}

.article-shell {
  padding: 6rem 0 7rem;
}

.article-header {
  max-width: 1040px;
  padding-bottom: 4rem;
  border-bottom: 1px solid var(--line-strong);
}

.article-header.compact {
  max-width: none;
}

.article-route {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.article-route a {
  color: var(--blue);
  text-decoration: none;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin-top: 2rem;
  color: var(--muted);
}

.article-grid {
  display: grid;
  grid-template-columns: 170px minmax(0, 760px);
  gap: 56px;
  align-items: start;
  padding-top: 4.5rem;
}

.article-rail {
  position: sticky;
  top: 2rem;
  display: flex;
  gap: 1.4rem;
  align-items: flex-start;
  height: 260px;
}

.article-rail span {
  display: block;
  width: 2px;
  height: 100%;
  background: var(--signal);
}

.article-rail small {
  color: var(--muted);
  line-height: 1;
  writing-mode: vertical-rl;
}

.article-content {
  min-width: 0;
  font-size: 1.04rem;
}

.article-content > :first-child {
  margin-top: 0;
}

.article-content h2,
.article-content h3,
.article-content h4 {
  font-family: var(--display);
  line-height: 1.25;
  scroll-margin-top: 2rem;
}

.article-content h2 {
  margin: 3.5rem 0 1.2rem;
  padding-top: 1.2rem;
  font-size: 2rem;
  border-top: 1px solid var(--line);
}

.article-content h3 {
  margin: 2.6rem 0 1rem;
  font-size: 1.45rem;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content table,
.article-content blockquote {
  margin-block: 1.2rem;
}

.article-content a {
  color: var(--blue);
}

.article-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2rem auto;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 8px 8px 0 var(--line);
}

.article-content blockquote {
  padding: 0.2rem 0 0.2rem 1.4rem;
  color: var(--muted);
  border-left: 3px solid var(--signal);
}

.article-content :not(pre) > code {
  padding: 0.14em 0.38em;
  color: var(--ink);
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--blue) 26%, var(--line));
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.88em;
}

.article-content pre,
.article-content .highlight {
  position: relative;
  max-width: 100%;
  margin: 1.8rem 0;
  overflow: auto;
  color: var(--code-ink);
  background: var(--code);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 7px 7px 0 var(--line);
}

.article-content pre {
  padding: 1.25rem 1.4rem;
}

.article-content .highlight pre {
  margin: 0;
  border: 0;
  box-shadow: none;
}

.article-content pre code,
.article-content .highlight code {
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.75;
}

.article-content .highlight table,
.article-content .highlight td {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
}

.article-content .highlight .gutter {
  padding: 1.25rem 0.85rem 1.25rem 1rem;
  color: var(--line-strong);
  text-align: right;
  user-select: none;
}

.article-content .highlight .code {
  width: 100%;
  padding: 1.25rem 1.4rem 1.25rem 0.3rem;
}

.copy-code {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
  padding: 0.35rem 0.55rem;
  color: var(--code-ink);
  background: var(--code);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.article-content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

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

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

.article-content hr {
  margin: 3rem 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
}

.article-footer {
  max-width: 986px;
  margin-top: 4.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line-strong);
}

.post-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 3rem;
}

.post-navigation a {
  display: flex;
  flex-direction: column;
  min-height: 120px;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  box-shadow: 5px 5px 0 var(--line);
}

.post-navigation a:last-child {
  text-align: right;
}

.post-navigation small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.post-navigation strong {
  margin-top: 0.65rem;
  font-family: var(--display);
  font-size: 1.2rem;
  line-height: 1.3;
}

.pagination {
  margin-top: 4rem;
  font-family: var(--mono);
}

.pagination a,
.pagination span {
  display: inline-block;
  min-width: 2.4rem;
  margin-right: 0.4rem;
  padding: 0.4rem 0.65rem;
  text-align: center;
  border: 1px solid var(--line);
  text-decoration: none;
}

.pagination .current {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 2rem 0 3rem;
  color: var(--muted);
  border-top: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 0.4rem;
  background: var(--signal);
  border-radius: 50%;
}

@media (max-width: 820px) {
  .site-header,
  .site-footer,
  main {
    width: min(100% - 32px, 720px);
  }

  .site-header {
    align-items: flex-start;
    min-height: auto;
    padding: 1.4rem 0;
  }

  .header-actions {
    gap: 0.8rem;
  }

  .site-nav {
    gap: 0.9rem;
  }

  .site-nav a {
    font-size: 0.82rem;
  }

  .site-nav a:last-child {
    display: none;
  }

  .brand-copy small {
    display: none;
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 5rem 0;
  }

  .hero-instrument {
    justify-self: start;
    width: min(70vw, 300px);
  }

  .article-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .article-rail {
    display: none;
  }
}

@media (max-width: 620px) {
  body {
    background-size: 32px 32px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-mark::before {
    height: 44px;
  }

  .brand-mark::after {
    width: 44px;
  }

  .brand-copy strong {
    font-size: 0.95rem;
  }

  .site-nav a:nth-child(2) {
    display: none;
  }

  .home-hero h1 {
    font-size: clamp(3.2rem, 16vw, 5rem);
  }

  .feed-section,
  .listing-page,
  .article-shell {
    padding: 4.5rem 0 5rem;
  }

  .section-heading {
    align-items: flex-start;
    gap: 1rem;
  }

  .signal-list::before {
    left: 6px;
  }

  .signal-entry {
    grid-template-columns: 1fr;
    gap: 0.7rem;
    padding: 0 0 3.5rem 30px;
  }

  .signal-node {
    top: 0.15rem;
    left: 0;
  }

  .signal-meta {
    flex-direction: row;
    gap: 0.8rem;
    text-align: left;
  }

  .article-header h1,
  .listing-header h1 {
    font-size: clamp(2.7rem, 14vw, 4.2rem);
  }

  .post-navigation {
    grid-template-columns: 1fr;
  }

  .post-navigation a:last-child {
    text-align: left;
  }

  .site-footer {
    flex-direction: column;
    gap: 0.35rem;
  }

  .site-footer p {
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
