:root {
  color-scheme: light dark;
  --paper: #f2f4f1;
  --paper-raised: #fafbf8;
  --paper-soft: #e7ebe6;
  --ink: #1c211e;
  --muted: #59635c;
  --line: #c8d0ca;
  --accent: #466852;
  --accent-strong: #294936;
  --accent-soft: #dce7df;
  --shadow: 0 22px 60px rgba(43, 54, 46, 0.14);
  --radius: 14px;
  --page: min(1180px, calc(100vw - 40px));
}

html[data-theme="dark"] {
  --paper: #171a18;
  --paper-raised: #202421;
  --paper-soft: #292f2b;
  --ink: #edf0ec;
  --muted: #aeb8b0;
  --line: #3b453e;
  --accent: #8db29a;
  --accent-strong: #c6ddcd;
  --accent-soft: #293b30;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --paper: #171a18;
    --paper-raised: #202421;
    --paper-soft: #292f2b;
    --ink: #edf0ec;
    --muted: #aeb8b0;
    --line: #3b453e;
    --accent: #8db29a;
    --accent-strong: #c6ddcd;
    --accent-soft: #293b30;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 3%, color-mix(in srgb, var(--accent-soft) 55%, transparent), transparent 28rem),
    var(--paper);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
  font-size: 17px;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-strong); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
img { display: block; max-width: 100%; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  transform: translateY(-160%);
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--paper-raised);
  background: var(--accent-strong);
}
.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(18px);
}

.nav {
  width: var(--page);
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  margin-right: auto;
  color: var(--ink);
  font-weight: 760;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  white-space: nowrap;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

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

.theme-toggle {
  min-width: 60px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--ink);
  background: var(--paper-raised);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.theme-toggle:active,
.button:active { transform: translateY(1px); }

.page { width: var(--page); margin: 0 auto; }

.hero {
  min-height: min(760px, calc(100dvh - 68px));
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(460px, 1.25fr);
  align-items: center;
  gap: clamp(36px, 6vw, 88px);
  padding: 64px 0 72px;
}

.hero-copy { max-width: 570px; }

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 780;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin-top: 0;
  line-height: 1.12;
  letter-spacing: -0.045em;
}

h1 { margin-bottom: 22px; font-size: clamp(3rem, 7vw, 6.4rem); font-weight: 790; }
h2 { margin-bottom: 18px; font-size: clamp(2rem, 4vw, 3.8rem); font-weight: 760; }
h3 { margin-bottom: 10px; font-size: 1.25rem; font-weight: 740; letter-spacing: -0.025em; }

.hero-lede {
  max-width: 38ch;
  margin: 0 0 30px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.8vw, 1.28rem);
}

.hero-visual { position: relative; }
.hero-visual img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.caption { margin: 12px 0 0; color: var(--muted); font-size: 0.76rem; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid var(--accent-strong);
  border-radius: 999px;
  color: var(--paper-raised);
  background: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 740;
  text-decoration: none;
  transition: transform 150ms ease, background 150ms ease;
  white-space: nowrap;
}
.button.secondary { color: var(--ink); background: transparent; border-color: var(--line); }
.button:hover { text-decoration: none; transform: translateY(-1px); }

.section { padding: clamp(74px, 10vw, 130px) 0; }
.section.compact { padding: 56px 0; }
.section-copy { max-width: 65ch; margin-bottom: 42px; }
.section-copy p { color: var(--muted); }

.status-band {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}
.status-item { min-height: 112px; padding: 22px; background: var(--paper-raised); }
.status-item strong { display: block; margin-bottom: 5px; font-size: 1.05rem; }
.status-item span { color: var(--muted); font-size: 0.86rem; }

.device-grid {
  display: grid;
  grid-template-columns: 1.16fr 0.84fr;
  gap: 22px;
}
.device-card {
  min-height: 440px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(28px, 4vw, 52px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
}
.device-card.k4 {
  color: #eef2ee;
  background:
    linear-gradient(180deg, rgba(22, 28, 24, 0.08), rgba(22, 28, 24, 0.94)),
    url('../images/k4-library.png') center 18% / cover no-repeat;
}
.device-card.dx { background: var(--accent-soft); }
.device-card p { max-width: 32ch; margin: 0 0 22px; color: inherit; opacity: 0.84; }
.device-card .button { align-self: flex-start; }
.device-card.k4 .button { border-color: #eef2ee; color: #182019; background: #eef2ee; }

.workflow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  counter-reset: workflow;
}
.workflow article {
  counter-increment: workflow;
  padding-top: 18px;
  border-top: 3px solid var(--accent);
}
.workflow article::before {
  content: counter(workflow, decimal-leading-zero);
  display: block;
  margin-bottom: 28px;
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}
.workflow p { margin: 0; color: var(--muted); font-size: 0.94rem; }

.feature-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(36px, 7vw, 100px);
  align-items: start;
}
.sticky-copy { position: sticky; top: 108px; }

.feature-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.feature {
  min-height: 210px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
}
.feature:nth-child(3n + 2) { background: var(--accent-soft); }
.feature p { margin: 0; color: var(--muted); font-size: 0.93rem; }

.media-split {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(34px, 7vw, 96px);
  align-items: center;
}
.media-split.reverse { grid-template-columns: minmax(0, 1.28fr) minmax(280px, 0.72fr); }
.media-split img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.media-split .copy { max-width: 58ch; }
.media-split .copy p { color: var(--muted); }

.key-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 28px; }
.key-row { display: grid; grid-template-columns: 132px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.key-row kbd {
  align-self: start;
  width: fit-content;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-raised);
  font: 650 0.78rem ui-monospace, SFMono-Regular, Menlo, monospace;
}
.key-row span { color: var(--muted); font-size: 0.9rem; }

.callout {
  margin: 34px 0;
  padding: 22px 24px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
}
.callout strong { display: block; margin-bottom: 4px; }
.callout p { margin: 0; }

.path {
  display: block;
  overflow-x: auto;
  padding: 18px 20px;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper-soft);
  font: 0.88rem/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}

.checklist { padding: 0; list-style: none; }
.checklist li { position: relative; padding: 12px 0 12px 34px; }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-strong); font-weight: 800; }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.fact { padding: 22px; border-radius: var(--radius); background: var(--paper-raised); border: 1px solid var(--line); }
.fact dt { color: var(--muted); font-size: 0.8rem; }
.fact dd { margin: 6px 0 0; font-weight: 720; }

.toc { padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); }
.toc strong { display: block; margin-bottom: 8px; }
.toc a { margin-right: 18px; }

.article-hero { max-width: 880px; padding: 88px 0 58px; }
.article-hero h1 { font-size: clamp(2.8rem, 6vw, 5.4rem); }
.article-hero p { max-width: 55ch; color: var(--muted); font-size: 1.18rem; }

.article { max-width: 920px; padding-bottom: 110px; }
.article section { padding-top: 82px; }
.article section p, .article section li { max-width: 72ch; }
.article table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.article th, .article td { padding: 14px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.article th { color: var(--muted); font-size: 0.78rem; }
.article code { padding: 0.15em 0.38em; border-radius: 5px; background: var(--paper-soft); font-size: 0.88em; }
.article pre code { padding: 0; background: transparent; }

.source-list { padding-left: 1.1em; }
.source-list li { margin: 9px 0; }

.footer {
  border-top: 1px solid var(--line);
  padding: 34px 0 48px;
  color: var(--muted);
  font-size: 0.82rem;
}
.footer-inner { width: var(--page); margin: 0 auto; display: flex; justify-content: space-between; gap: 24px; }

@media (max-width: 900px) {
  :root { --page: min(100% - 30px, 720px); }
  .nav { min-height: 62px; gap: 12px; }
  .nav-links { gap: 12px; overflow-x: auto; }
  .nav-links a { font-size: 0.82rem; }
  .brand { display: none; }
  .theme-toggle { margin-left: auto; }
  .hero { min-height: auto; grid-template-columns: 1fr; gap: 36px; padding: 52px 0 72px; }
  .hero-copy { max-width: none; }
  .status-band { grid-template-columns: 1fr 1fr; }
  .device-grid, .feature-layout, .media-split, .media-split.reverse { grid-template-columns: 1fr; }
  .sticky-copy { position: static; }
  .workflow { grid-template-columns: 1fr 1fr; }
  .media-split.reverse .copy { order: 2; }
  .key-grid { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  body { font-size: 16px; }
  .nav { overflow: hidden; }
  .nav-links { flex: 1; }
  .theme-toggle { min-width: 52px; font-size: 0.7rem; }
  h1 { font-size: clamp(2.65rem, 14vw, 4.2rem); }
  .status-band, .workflow, .feature-list, .facts { grid-template-columns: 1fr; }
  .device-card { min-height: 370px; }
  .key-row { grid-template-columns: 112px 1fr; }
  .toc a { display: block; margin: 7px 0; }
  .article table { display: block; overflow-x: auto; }
  .footer-inner { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
