:root {
  --paper: #f3efe6;
  --sheet: #fffcf7;
  --ink: #1d1b17;
  --mute: #6d675e;
  --line: #ddd6c8;
  --accent: #c94b2a;
  --accent-deep: #a63b20;
  --ok: #2f7a55;
  --max: 1180px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", sans-serif;
  line-height: 1.55;
  padding-top: calc(60px + env(safe-area-inset-top, 0px));
}

a {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.skip {
  position: absolute;
  left: 12px;
  top: 8px;
  z-index: 80;
  padding: 8px 12px;
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
  transform: translateY(-160%);
}

.skip:focus {
  transform: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

ul,
ol {
  padding-left: 1.15em;
}

li + li {
  margin-top: 6px;
}

.page-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(29, 27, 23, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 27, 23, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(243, 239, 230, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
  box-shadow: 0 1px 2px rgba(29, 27, 23, 0.08);
}

.topbar-nav {
  display: flex;
  gap: 16px;
  margin-left: auto;
  font-size: 14px;
}

.topbar-nav a {
  text-decoration: none;
  color: var(--mute);
}

.topbar-nav a:hover {
  color: var(--ink);
}

.topbar-nav a.is-current {
  color: var(--ink);
  font-weight: 600;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--sheet);
  border: 1px solid var(--line);
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--ink);
}

.nav-toggle span {
  position: relative;
}

.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle span::before {
  top: -5px;
}

.nav-toggle span::after {
  top: 5px;
}

.topbar.is-open .nav-toggle span {
  background: transparent;
}

.topbar.is-open .nav-toggle span::before {
  top: 0;
  transform: rotate(45deg);
}

.topbar.is-open .nav-toggle span::after {
  top: 0;
  transform: rotate(-45deg);
}

.lang-switch {
  position: relative;
}

.lang-switch-btn {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 10px 5px 8px;
  background: var(--sheet);
  border: 1px solid var(--line);
  font-size: 13px;
}

.lang-switch-btn:hover {
  border-color: var(--ink);
}

.lang-switch.is-open .lang-switch-btn {
  border-color: var(--ink);
}

.lang-switch-kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.lang-switch-now {
  font-weight: 600;
}

.lang-switch-caret {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid var(--mute);
  align-self: center;
}

.lang-switch.is-open .lang-switch-caret {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 148px;
  background: var(--sheet);
  border: 1px solid var(--ink);
  padding: 4px;
  z-index: 30;
}

.lang-menu a,
.lang-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--mute);
  text-decoration: none;
}

.lang-menu a:hover,
.lang-menu button:hover {
  color: var(--ink);
  background: #faf6ee;
}

.lang-menu a.is-current,
.lang-menu button.is-current {
  color: var(--ink);
  font-weight: 600;
}

.lang-menu a.is-current::after,
.lang-menu button.is-current::after {
  content: "✓";
  float: right;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
}

.progress {
  position: fixed;
  z-index: 15;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--mute);
}

.progress b {
  color: var(--accent);
  font-weight: 500;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px 28px;
  align-items: start;
  padding: 24px 0 20px;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.hero-brand img {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.hero-brand h1 {
  margin: 0;
}

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.hero-lead {
  margin-top: 12px;
  font-size: 16px;
  color: var(--mute);
}

.spec {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  padding: 16px 18px;
  background: var(--sheet);
  border: 1px solid var(--line);
}

.spec dt {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute);
}

.spec dd {
  margin-top: 2px;
  font-size: 15px;
}

.license {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  margin-bottom: 28px;
  background: var(--sheet);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(29, 27, 23, 0.05);
}

.license::after {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 4px;
  background: var(--accent);
}

.license {
  position: relative;
}

.license-main,
.license-side {
  padding: 20px 22px;
}

.app-listing {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.app-listing img {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
}

.app-listing strong {
  display: block;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.app-listing em {
  display: block;
  font-style: normal;
  color: var(--mute);
  font-size: 13px;
  margin-top: 2px;
}

.license-side {
  border-left: 1px dashed var(--line);
  background: #faf6ee;
  color: var(--mute);
  font-size: 14px;
}

.kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.license h2,
.section-head h2 {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 6px 0 8px;
}

.license-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.license-meta span {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff8f4;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.btn:hover {
  background: var(--accent-deep);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  border-color: var(--ink);
}

.guide,
.faq,
.wrap,
.chapter,
.article h2 {
  scroll-margin-top: calc(76px + env(safe-area-inset-top, 0px));
}

.wrap + .wrap,
.license + .wrap {
  padding-top: 8px;
}

.section-head {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px 24px;
  align-items: end;
  margin-bottom: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-head p {
  color: var(--mute);
  font-size: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.cards article,
.panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  padding: 14px 16px;
}

.cards h3,
.panel h3,
.step h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.cards h3 a {
  text-decoration: none;
}

.cards h3 a:hover {
  color: var(--accent);
}

.step h3 a {
  text-decoration: none;
}

.step h3 a:hover {
  color: var(--accent);
}

.cards p,
.panel,
.step p,
.step li,
.qa .a {
  color: var(--mute);
  font-size: 14px;
}

.step {
  display: grid;
  grid-template-columns: 48px 1fr 250px;
  gap: 16px 20px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.step-index {
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.04em;
}

.step ol {
  margin: 10px 0 0;
  display: grid;
  gap: 4px;
}

.check {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink);
}

.check input {
  accent-color: var(--ok);
  width: 15px;
  height: 15px;
}

.step-note {
  padding: 12px 14px;
  background: var(--sheet);
  border: 1px solid var(--line);
  align-self: start;
  font-size: 13px;
  color: var(--mute);
}

.step-note strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--sheet);
  margin-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  background: #faf6ee;
  font-weight: 500;
}

td:first-child {
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}

.split {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.prose {
  color: #3f3b35;
  font-size: 15px;
  max-width: none;
}

.prose p + p {
  margin-top: 10px;
}

.prose code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  background: #faf6ee;
  border: 1px solid var(--line);
  padding: 0 5px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 12px 0 8px;
}

.gallery figure {
  margin: 0;
  background: var(--sheet);
  border: 1px solid var(--line);
}

.gallery img {
  width: 100%;
  display: block;
  background: #fff;
}

.gallery figcaption {
  padding: 6px 8px 8px;
  font-size: 12px;
  color: var(--mute);
}

.article {
  padding-bottom: 36px;
}

.article .prose {
  margin-top: 8px;
}

.article h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 22px 0 8px;
}

.faq {
  padding-bottom: 36px;
}

.qa {
  border-top: 1px solid var(--line);
}

.qa button {
  width: 100%;
  text-align: left;
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 16px;
  font-weight: 500;
}

.qa button span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--accent);
}

.qa .a {
  display: none;
  padding: 0 0 12px;
}

.qa.open .a {
  display: block;
}

footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  padding: 16px 0 28px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--mute);
  font-size: 13px;
}

@media (max-width: 900px) {
  .progress {
    display: none;
  }

  body {
    padding-top: calc(56px + env(safe-area-inset-top, 0px));
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  .topbar-tools {
    grid-column: 2;
    grid-row: 1;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .topbar-nav {
    display: none;
    grid-column: 1 / -1;
    margin-left: 0;
    flex-direction: column;
    gap: 0;
  }

  .topbar.is-open .topbar-nav {
    display: flex;
  }

  .topbar-nav a {
    padding: 12px 0;
    border-top: 1px solid var(--line);
    font-size: 16px;
  }

  .wrap {
    width: min(var(--max), calc(100% - 32px));
  }

  .hero,
  .spec,
  .license,
  .step,
  .license-meta,
  .cards,
  .split,
  .split-2,
  .section-head,
  .app-listing {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 16px 0 12px;
    gap: 16px;
  }

  .hero-brand {
    align-items: flex-start;
  }

  .hero-brand img {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
  }

  .gallery {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .gallery figure {
    flex: 0 0 44%;
    scroll-snap-align: start;
  }

  .license-main,
  .license-side {
    padding: 16px;
  }

  .license-side {
    border-left: 0;
    border-top: 1px dashed var(--line);
  }

  .actions .btn {
    min-height: 44px;
  }

  td:first-child {
    white-space: normal;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .article h2 {
    font-size: 20px;
  }

  footer {
    flex-direction: column;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .wrap {
    width: min(var(--max), calc(100% - 24px));
  }

  .page-grid {
    background-size: 28px 28px;
  }

  .hero h1 {
    font-size: 32px;
  }

  .hero-lead,
  .prose,
  .doc-hero p {
    font-size: 15px;
  }

  .spec {
    grid-template-columns: 1fr 1fr;
    padding: 12px 14px;
  }

  .gallery figure {
    flex: 0 0 58%;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .actions .btn {
    width: 100%;
  }

  .qa button {
    font-size: 15px;
    padding: 14px 0;
  }
}
