:root {
  --paper: #f4f1e9;
  --paper-deep: #ebe4d4;
  --ink: #111111;
  --muted: #4a463c;
  --rule: rgba(17, 17, 17, 0.18);
  --hairline: rgba(17, 17, 17, 0.1);
  --glow: rgba(255, 255, 255, 0.35);
  --serif: "Songti SC", "STSong", "Songti SC Regular", Georgia, "Times New Roman", serif;
  --meta: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 38rem;
  color-scheme: light;
}

html[data-theme="dark"] {
  --paper: #1b1914;
  --paper-deep: #14120e;
  --ink: #f4f1e9;
  --muted: #c4bba8;
  --rule: rgba(244, 241, 233, 0.2);
  --hairline: rgba(244, 241, 233, 0.12);
  --glow: rgba(255, 236, 200, 0.06);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --paper: #1b1914;
    --paper-deep: #14120e;
    --ink: #f4f1e9;
    --muted: #c4bba8;
    --rule: rgba(244, 241, 233, 0.2);
    --hairline: rgba(244, 241, 233, 0.12);
    --glow: rgba(255, 236, 200, 0.06);
    color-scheme: dark;
  }
}

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

html {
  background: var(--paper);
  color: var(--ink);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.7;
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--glow), transparent 55%),
    var(--paper);
  color: var(--ink);
}

::selection { background: var(--ink); color: var(--paper); }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--ink); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
strong { font-weight: 600; }
code { font-family: var(--mono); font-size: 0.92em; }

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.4rem 0.8rem;
  z-index: 10;
}
.skip:focus { top: 0.6rem; }

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

.mast {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--ink);
  background: color-mix(in srgb, var(--paper) 87%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mast-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1.5rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.05rem 1.25rem 0.95rem;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  font-family: var(--meta);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}
.wordmark img { width: 28px; height: 28px; }
html[data-theme="dark"] .wordmark img,
html[data-theme="dark"] .colophon img { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .wordmark img,
  html:not([data-theme="light"]) .colophon img { filter: invert(1); }
}

.mast-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem 1.2rem;
}

.prefs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.pref {
  display: inline-flex;
  border: 1px solid var(--rule);
}

.pref button {
  font-family: var(--meta);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0.28rem 0.65rem;
  min-height: 2rem;
  cursor: pointer;
}

.pref button + button { border-left: 1px solid var(--rule); }
.pref button:hover { color: var(--ink); }
.pref button[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.15rem;
  font-family: var(--meta);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}
nav a { text-decoration: none; }
nav a:hover { text-decoration: underline; }

section[id] { scroll-margin-top: 4.5rem; }

.hero,
.sheet,
.colophon {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 3rem 3.2rem;
  align-items: center;
  padding-top: 3.4rem;
  padding-bottom: 3.4rem;
  border-bottom: 1px solid var(--ink);
}
.hero-copy { min-width: 0; }

.kicker {
  margin: 0 0 0.85rem;
  font-family: var(--meta);
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3 { font-weight: 600; letter-spacing: 0.02em; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 8vw, 4.35rem); margin: 0 0 1.15rem; }
h2 { font-size: clamp(1.7rem, 3vw, 2.35rem); margin: 0; }
h3 { font-size: 1.2rem; margin: 0 0 0.45rem; }

.lede {
  max-width: var(--measure);
  margin: 0 0 1.5rem;
  font-size: 1.12rem;
  color: var(--ink);
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.4rem;
  margin: 0 0 1rem;
}

.btn {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  padding: 0.7rem 1.25rem;
  letter-spacing: 0.08em;
  font-family: var(--meta);
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px var(--ink);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.btn:hover {
  background: transparent;
  color: var(--ink);
}

.text-btn {
  font-family: var(--meta);
  letter-spacing: 0.04em;
}

.fine, .note, .more {
  color: var(--muted);
  font-size: 0.95rem;
}
.fine { margin: 0; max-width: 28rem; }

.hero-scene {
  margin: 0;
  min-width: 0;
}
.hero-scene img {
  width: 100%;
  height: auto;
  aspect-ratio: 1024 / 576;
  object-fit: cover;
  border: 1px solid var(--ink);
}
.hero-scene figcaption {
  margin-top: 1.05rem;
  text-align: right;
  font-family: var(--meta);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sheet {
  padding-top: 3.1rem;
  padding-bottom: 3.1rem;
  border-bottom: 1px solid var(--rule);
}
.sheet-head { margin-bottom: 1.8rem; max-width: 36rem; }

.folio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem 2rem;
}
.folio article {
  padding-top: 1rem;
  border-top: 1px solid var(--ink);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 3rem;
}
.split ul {
  margin: 0;
  padding-left: 1.1rem;
}
.split li + li { margin-top: 0.35rem; }
.note { margin: 1.6rem 0 0; max-width: 46rem; }

.look {
  display: grid;
  grid-template-columns: minmax(0, 0.42fr) minmax(0, 1fr);
  gap: 2rem 2.6rem;
  align-items: start;
}
.look figure {
  margin: 0;
  border: 1px solid var(--ink);
  background: var(--paper);
}
.look img {
  width: 100%;
  height: auto;
  aspect-ratio: 1072 / 1448;
  object-fit: contain;
}
.look figcaption {
  margin: 0;
  padding: 0.7rem 0.85rem 0.8rem;
  border-top: 1px solid var(--hairline);
  font-family: var(--meta);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.6rem;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
.steps h3::before {
  content: counter(step, decimal-leading-zero) "  ";
  font-family: var(--meta);
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 0.85em;
}

.cmd {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: start;
  margin-top: 0.7rem;
  background: var(--paper-deep);
  border: 1px solid var(--ink);
  padding: 0.7rem 0.75rem;
}
.cmd pre {
  margin: 0;
  min-width: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
}
.cmd button {
  font-family: var(--meta);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.cmd button:hover { background: var(--muted); }
.cmd button[data-copied="1"] { background: transparent; color: var(--ink); border: 1px solid var(--ink); }

.more { margin: 1.8rem 0 0; }

.colophon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 1.2rem;
  padding-top: 1.6rem;
  padding-bottom: 2.4rem;
  font-family: var(--meta);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.colophon p { margin: 0; }
.colophon img { width: 24px; height: 24px; }

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 2.6rem;
    padding-top: 2.4rem;
    padding-bottom: 2.8rem;
  }
  .hero-scene { width: 100%; }
  .folio, .split, .look { grid-template-columns: 1fr; }
  .look { max-width: 22rem; }
}

@media (max-width: 520px) {
  body { font-size: 1rem; }
  .mast-inner { padding: 0.85rem 1rem 0.8rem; }
  .hero, .sheet, .colophon { padding-left: 1rem; padding-right: 1rem; }
  nav { font-size: 0.85rem; gap: 0.3rem 0.9rem; }
  .pref button { font-size: 0.72rem; padding: 0.26rem 0.5rem; }
  h1 { font-size: clamp(1.85rem, 9vw, 2.5rem); }
  .hero-scene figcaption { text-align: center; }
  .cmd { grid-template-columns: 1fr; }
  .cmd pre { font-size: 0.8rem; }
  .cmd button { justify-self: start; }
}

@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise 0.7s ease both; }
  .hero-copy.rise { animation-delay: 0.04s; }
  .hero-scene.rise { animation-delay: 0.14s; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

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