:root {
  --color-page: #faf9f6;
  --color-surface: #ffffff;
  --color-surface-soft: #f1efea;
  --color-surface-deep: #e9e6df;
  --color-border: #d8d5ce;
  --color-border-strong: #b9b5ac;
  --color-ink: #11110f;
  --color-muted: #69665f;
  --color-faint: #969188;
  --color-accent: #e58a00;
  --color-accent-dark: #a85e00;
  --color-accent-soft: #fff0d3;
  --color-accent-glow: rgba(229, 138, 0, 0.22);
  --color-success: #287a4d;
  --color-success-soft: rgba(40, 122, 77, 0.12);
  --color-warning: #9b6500;
  --color-error: #b23a32;
  --color-rack: #10100e;
  --color-rack-raised: #191916;
  --color-rack-soft: #22221e;
  --color-rack-edge: #34332e;
  --color-rack-copy: #f7f5ef;
  --color-rack-muted: #aaa69d;
  --color-rack-line: #4a4942;
  --color-panel-shadow: rgba(17, 17, 15, 0.2);
  --color-soft-shadow: rgba(17, 17, 15, 0.08);
  --color-deep-shadow: rgba(17, 17, 15, 0.32);
  --color-grid: rgba(17, 17, 15, 0.038);
  --color-orbit: rgba(17, 17, 15, 0.12);
  --color-white-alpha: rgba(255, 255, 255, 0.1);
  --color-white-alpha-strong: rgba(255, 255, 255, 0.18);
  --color-black-alpha: rgba(0, 0, 0, 0.22);
  --flag-red: #d83b37;
  --flag-red-dark: #b62031;
  --flag-blue: #244887;
  --flag-blue-dark: #153970;
  --flag-white: #ffffff;
  --flag-black: #171715;
  --flag-gold: #f0c04a;
  --font-display: Inter, "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", system-ui, sans-serif;
  --font-body: Inter, "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --radius-xs: 4px;
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;
  --shadow-panel: 0 30px 72px var(--color-panel-shadow), 0 8px 20px var(--color-soft-shadow);
  --shadow-button: 0 16px 32px var(--color-black-alpha), 0 3px 7px var(--color-soft-shadow);
  --header-height: 72px;
  --content-width: 1360px;
  --reading-width: 48rem;
  --gutter: clamp(16px, 4vw, 32px);
  --section-space: clamp(72px, 10vw, 132px);
  --toc-offset: 88px;
  --transition-fast: 160ms ease;
  --transition-reveal: 620ms cubic-bezier(.2, .75, .25, 1);
}

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

html {
  color: var(--color-ink);
  background: var(--color-page);
  font-family: var(--font-body);
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

html.nav-open {
  overflow: hidden;
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  background:
    linear-gradient(var(--color-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid) 1px, transparent 1px),
    var(--color-page);
  background-size: 72px 72px;
  color: var(--color-ink);
  font-size: 16px;
  line-height: 1.72;
}

main,
section,
article,
aside,
header,
footer,
nav,
div {
  min-width: 0;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea,
summary {
  color: inherit;
  font: inherit;
}

button,
summary {
  cursor: pointer;
}

button {
  border: 0;
}

p,
ul,
ol,
blockquote,
pre,
table {
  margin-top: 0;
}

p {
  margin-bottom: 1.25em;
}

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

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
}

:not(pre) > code {
  padding: 0.12em 0.35em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--color-surface-soft);
  overflow-wrap: anywhere;
}

pre {
  max-width: 100%;
  padding: 18px;
  overflow-x: auto;
  border: 1px solid var(--color-rack-edge);
  border-radius: var(--radius-sm);
  background: var(--color-rack);
  color: var(--color-rack-copy);
  -webkit-overflow-scrolling: touch;
}

pre code {
  white-space: pre;
}

hr {
  margin: 40px 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

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

.wrap {
  width: 100%;
  max-width: calc(var(--content-width) + (var(--gutter) * 2));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.reading-wrap {
  width: 100%;
  max-width: calc(var(--reading-width) + (var(--gutter) * 2));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-top: var(--section-space);
  padding-bottom: var(--section-space);
  overflow-x: clip;
}

.section-tight {
  padding-top: calc(var(--section-space) * 0.62);
  padding-bottom: calc(var(--section-space) * 0.62);
  overflow-x: clip;
}

.surface-section {
  border-block: 1px solid var(--color-border);
  background: var(--color-surface);
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  text-wrap: balance;
}

h1,
.hero-title {
  max-width: 16ch;
  margin-bottom: 24px;
  font-size: clamp(52px, 5.3vw, 72px);
  font-weight: 790;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

h2 {
  margin-bottom: 20px;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 760;
  letter-spacing: -0.02em;
  line-height: 1.14;
}

h3 {
  margin-bottom: 12px;
  font-size: clamp(21px, 2.2vw, 28px);
  line-height: 1.25;
}

h4 {
  margin-bottom: 10px;
  font-size: 18px;
}

.title-lock {
  white-space: nowrap;
}

.title-accent {
  color: var(--color-accent-dark);
}

.kicker,
.eyebrow {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 20px;
  padding: 7px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-muted);
  box-shadow: 0 7px 20px var(--color-soft-shadow);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.055em;
}

.status-dot,
.eyebrow-light {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: var(--color-success);
  box-shadow: 0 0 0 4px var(--color-success-soft);
}

.lead {
  max-width: 760px;
  color: var(--color-muted);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.65;
}

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

.mono {
  font-family: var(--font-mono);
}

.button,
.cta {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 720;
  line-height: 1;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.button:hover,
.cta:hover {
  transform: translateY(-2px);
}

.button:focus-visible,
.cta:focus-visible,
.nav-link:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--color-accent-glow);
  outline-offset: 3px;
}

.button-primary,
.cta-primary {
  border-color: var(--color-rack-edge);
  background: var(--color-rack);
  color: var(--color-rack-copy);
  box-shadow: var(--shadow-button);
}

.button-primary:hover,
.cta-primary:hover {
  background: var(--color-rack-raised);
}

.button-accent {
  border-color: var(--color-accent-dark);
  background: var(--color-accent);
  color: var(--color-ink);
}

.button-secondary,
.cta-secondary {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink);
  box-shadow: 0 7px 18px var(--color-soft-shadow);
}

.button-secondary:hover,
.cta-secondary:hover {
  border-color: var(--color-border-strong);
}

.button-ghost {
  border-color: var(--color-border);
  background: transparent;
  color: var(--color-muted);
}

.button[disabled],
.button.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
}

.card,
.panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.card {
  padding: clamp(20px, 3vw, 30px);
}

.panel {
  padding: clamp(24px, 4vw, 44px);
  box-shadow: 0 18px 50px var(--color-soft-shadow);
}

.badge,
.tag {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 9px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-accent {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
}

.site-header {
  position: relative;
  z-index: 100;
  min-height: var(--header-height);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-page);
}

.header-inner {
  width: 100%;
  max-width: calc(var(--content-width) + (var(--gutter) * 2));
  min-height: var(--header-height);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: max-content;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.brand-copy {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1;
}

.brand-latin {
  font-size: 17px;
  font-weight: 790;
  letter-spacing: -0.02em;
}

.brand-local {
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 540;
}

.primary-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.nav-link,
.more-menu > summary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-size: 14px;
  font-weight: 550;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.nav-link:hover,
.more-menu > summary:hover {
  color: var(--color-ink);
  background: var(--color-surface-soft);
}

.nav-link[aria-current="page"],
.more-menu.is-active > summary {
  color: var(--color-ink);
  font-weight: 720;
}

.more-menu,
.language-menu {
  position: relative;
}

.more-menu > summary,
.language-menu > summary {
  list-style: none;
}

.more-menu > summary::-webkit-details-marker,
.language-menu > summary::-webkit-details-marker {
  display: none;
}

.more-panel,
.language-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: 190px;
  padding: 7px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: 0 18px 42px var(--color-soft-shadow);
}

.more-panel a,
.language-panel a {
  min-height: 42px;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-size: 14px;
}

.more-panel a:hover,
.language-panel a:hover,
.language-panel a[aria-current="true"] {
  color: var(--color-ink);
  background: var(--color-surface-soft);
}

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

.language-toggle {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  font-size: 13px;
}

.language-toggle:hover {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink);
}

.login-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--color-ink);
  border-radius: var(--radius-sm);
  background: var(--color-ink);
  color: var(--color-surface);
  font-size: 14px;
  font-weight: 720;
}

.menu-toggle {
  min-width: 44px;
  min-height: 44px;
  display: none;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

.mobile-nav {
  display: none;
}

.nav-veil {
  display: none;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-rack);
  color: var(--color-rack-copy);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) repeat(3, minmax(150px, 1fr));
  gap: 48px;
  padding-top: 64px;
  padding-bottom: 50px;
}

.footer-brand p {
  max-width: 430px;
  margin-top: 18px;
  color: var(--color-rack-muted);
}

.footer-brand .brand-local {
  color: var(--color-rack-muted);
}

.footer-heading {
  margin-bottom: 16px;
  color: var(--color-rack-copy);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-links {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links a {
  color: var(--color-rack-muted);
  font-size: 14px;
}

.footer-links a:hover {
  color: var(--color-rack-copy);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-top: 22px;
  padding-bottom: 26px;
  border-top: 1px solid var(--color-rack-edge);
  color: var(--color-rack-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.reveal {
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.reveal.pending {
  opacity: 0;
  transform: translateY(16px);
}

.reveal.shown {
  opacity: 1;
  transform: none;
}

.tilt {
  transform: rotate(-0.35deg);
}

.prose {
  overflow-wrap: break-word;
}

.prose h2,
.prose h3 {
  scroll-margin-top: var(--toc-offset);
}

.prose blockquote {
  margin-inline: 0;
}

body:has(.toc-tabs) section[id] {
  scroll-margin-top: var(--toc-offset);
}

@media (max-width: 1040px) {
  .primary-nav {
    display: none;
  }

  .header-inner {
    grid-template-columns: auto 1fr;
  }

  .header-tools {
    margin-left: auto;
  }

  .menu-toggle {
    display: grid;
  }

  .language-menu {
    display: none;
  }

  .mobile-nav {
    position: absolute;
    z-index: 103;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100dvh - var(--header-height));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px var(--gutter) 20px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
  }

  .mobile-nav.is-open {
    display: block;
  }

  .mobile-nav ul {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mobile-nav a {
    min-height: 48px;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-muted);
  }

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

  .mobile-language-label {
    margin: 17px 12px 7px;
    color: var(--color-faint);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  .nav-veil {
    position: fixed;
    z-index: 90;
    inset: var(--header-height) 0 0;
    background: var(--color-black-alpha);
  }

  .nav-veil.is-open {
    display: block;
  }
}

@media (max-width: 768px) {
  h1,
  .hero-title {
    max-width: 100%;
    font-size: clamp(28px, 9.8vw, 40px);
    line-height: 1.12;
  }

  h2 {
    font-size: clamp(28px, 8vw, 38px);
  }

  .header-inner {
    gap: 10px;
  }

  .brand-local {
    display: none;
  }

  .login-button {
    padding-inline: 13px;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 34px 24px;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .footer-bottom {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
    --header-height: 64px;
    --toc-offset: 78px;
  }

  body {
    background-size: 48px 48px;
  }

  .section {
    padding-top: 72px;
    padding-bottom: 72px;
  }

  .section-tight {
    padding-top: 48px;
    padding-bottom: 48px;
  }

  .tilt,
  [class*="tilt"] {
    transform: none;
  }

  .button-row {
    align-items: stretch;
  }

  .button-row .button,
  .button-row .cta {
    flex: 1 1 140px;
  }

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

  .brand-copy {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-brand {
    grid-column: auto;
  }
}

@media (max-width: 374px) {
  .login-button {
    padding-inline: 10px;
    font-size: 13px;
  }

  .header-tools {
    gap: 5px;
  }
}

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

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

  .reveal,
  .reveal.pending {
    opacity: 1 !important;
    transform: none !important;
  }
}