:root {
  --color-bg: #161714;
  --color-bg-panel: #20211d;
  --color-bg-panel-2: #2a2b26;
  --color-border: #4b4d45;
  --color-border-soft: #373932;
  --color-accent: #83f2be;
  --color-accent-dark: #3dbd82;
  --color-text: #f4f0e4;
  --color-text-muted: #a9aa9f;
  --color-paper: #e9e3d2;
  --color-paper-ink: #292b26;
  --color-paper-muted: #77786f;
  --color-success: #83f2be;
  --color-warn: #e7c66b;
  --color-error: #e47b70;
  --color-black: #0e0f0d;
  --color-white: #ffffff;
  --color-flag-red: #d94c4c;
  --color-flag-red-dark: #b52b35;
  --color-flag-blue: #31547c;
  --color-flag-blue-bright: #3f69a1;
  --color-focus: #e9e3d2;
  --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-small: 6px;
  --radius-medium: 12px;
  --radius-large: 22px;
  --radius-pill: 999px;
  --gutter: clamp(16px, 4vw, 64px);
  --content-width: 1320px;
  --reading-width: 768px;
  --header-height: 76px;
  --section-space: clamp(72px, 10vw, 144px);
  --transition-fast: 180ms ease;
  --transition-slow: 560ms cubic-bezier(.2, .75, .25, 1);
  --toc-offset: 92px;
}

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

html {
  min-width: 320px;
  overflow-x: clip;
  color-scheme: dark;
  background: var(--color-bg);
  scroll-behavior: smooth;
}

html.nav-open {
  overflow: hidden;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  color: var(--color-text);
  background:
    radial-gradient(circle at 50% 22%, color-mix(in srgb, var(--color-accent) 8%, transparent), transparent 28%),
    linear-gradient(var(--color-bg), var(--color-bg));
  font-family: var(--font-body);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .24;
  background-image:
    linear-gradient(color-mix(in srgb, var(--color-text) 3%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--color-text) 3%, transparent) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, transparent, var(--color-black) 22%, transparent 76%);
}

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

img {
  height: auto;
}

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

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

button {
  cursor: pointer;
}

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

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

p {
  color: var(--color-text-muted);
}

strong {
  color: var(--color-text);
}

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

:not(pre) > code {
  padding: .12em .4em;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-small);
  color: var(--color-accent);
  background: var(--color-bg-panel);
  overflow-wrap: anywhere;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-black);
  -webkit-overflow-scrolling: touch;
}

pre code {
  white-space: pre;
  overflow-wrap: normal;
}

hr {
  height: 1px;
  margin: 48px 0;
  border: 0;
  background: var(--color-border-soft);
}

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

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

.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 {
  position: relative;
  overflow-x: clip;
  padding-top: var(--section-space);
  padding-bottom: var(--section-space);
}

.section-compact {
  padding-top: clamp(48px, 7vw, 88px);
  padding-bottom: clamp(48px, 7vw, 88px);
}

.grid-safe > *,
.flex-safe > * {
  min-width: 0;
}

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

h1,
.hero-title {
  margin-bottom: 20px;
  font-size: clamp(52px, 5.2vw, 68px);
  font-weight: 360;
  line-height: 1.1;
  letter-spacing: -.02em;
}

h2 {
  margin-bottom: 20px;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 420;
  line-height: 1.16;
  letter-spacing: -.015em;
}

h3 {
  margin-bottom: 14px;
  font-size: clamp(22px, 2.3vw, 30px);
  font-weight: 560;
  line-height: 1.3;
}

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

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

.kicker,
.eyebrow {
  display: inline-flex;
  min-height: 29px;
  max-width: 100%;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-bg-panel) 82%, transparent);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.kicker::before,
.eyebrow::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  content: "";
  background: var(--color-accent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--color-accent) 70%, transparent);
}

.accent-text {
  color: var(--color-accent);
}

.scan-text {
  color: var(--color-accent);
  background: linear-gradient(90deg, var(--color-accent), var(--color-text), var(--color-accent));
  background-size: 220% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: title-scan 8s ease-in-out infinite;
}

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

.mono-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.button,
.cta {
  display: inline-flex;
  min-height: 43px;
  min-width: 126px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  background: var(--color-bg-panel);
  font-size: 14px;
  font-weight: 620;
  line-height: 1;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.button:hover,
.cta:hover {
  transform: translateY(-2px);
  border-color: var(--color-text-muted);
}

.button-primary,
.cta-primary {
  border-color: var(--color-accent);
  color: var(--color-bg);
  background: var(--color-accent);
}

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

.button-quiet {
  background: transparent;
}

.button-danger {
  border-color: var(--color-error);
  color: var(--color-error);
}

.button[disabled] {
  cursor: not-allowed;
  opacity: .46;
  transform: none;
}

.button svg,
.cta svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.button svg *,
.cta svg * {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.panel,
.card {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-bg-panel);
}

.panel {
  padding: clamp(22px, 3vw, 36px);
}

.paper-panel {
  color: var(--color-paper-ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 5px, color-mix(in srgb, var(--color-paper-ink) 4%, transparent) 6px),
    var(--color-paper);
}

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

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

.status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: var(--color-success);
}

.site-header {
  position: relative;
  z-index: 100;
  width: min(calc(100% - (var(--gutter) * 2)), var(--content-width));
  min-height: var(--header-height);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--color-border-soft);
}

.site-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.site-brand img {
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border-radius: var(--radius-small);
}

.brand-local {
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 450;
}

.desktop-nav {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  color: var(--color-text-muted);
  font-size: 13px;
}

.desktop-nav a {
  transition: color var(--transition-fast);
}

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

.desktop-nav a + a::before {
  margin: 0 9px;
  color: var(--color-border);
  content: "·";
}

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

.language-switch {
  position: relative;
}

.language-trigger {
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  color: var(--color-text-muted);
  background: transparent;
  font-size: 12px;
}

.language-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 120;
  width: 168px;
  display: none;
  padding: 7px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-bg-panel-2);
}

.language-menu.is-open {
  display: grid;
}

.language-menu a {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  border-radius: var(--radius-small);
  color: var(--color-text-muted);
  font-size: 12px;
}

.language-menu a:hover,
.language-menu a[aria-current="true"] {
  color: var(--color-text);
  background: var(--color-bg-panel);
}

.login-button {
  min-width: 66px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  background: var(--color-bg-panel);
  font-size: 13px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.login-button:hover {
  border-color: var(--color-accent);
  background: var(--color-bg-panel-2);
}

.menu-toggle {
  min-width: 44px;
  min-height: 44px;
  display: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-bg-panel);
}

.menu-toggle span,
.menu-toggle::before,
.menu-toggle::after {
  width: 17px;
  height: 1px;
  display: block;
  content: "";
  background: var(--color-text);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.menu-toggle::before {
  transform: translateY(-5px);
}

.menu-toggle::after {
  transform: translateY(5px);
}

.menu-toggle[aria-expanded="true"] span {
  opacity: 0;
}

.menu-toggle[aria-expanded="true"]::before {
  transform: translateY(1px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"]::after {
  transform: translateY(-1px) rotate(-45deg);
}

.mobile-nav {
  position: fixed;
  top: var(--header-height);
  right: var(--gutter);
  left: var(--gutter);
  z-index: 115;
  max-height: calc(100dvh - var(--header-height) - 12px);
  display: none;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-bg-panel-2);
  overscroll-behavior: contain;
}

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

.mobile-nav a {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--color-text-muted);
}

.mobile-nav a:hover,
.mobile-nav a[aria-current="page"] {
  color: var(--color-text);
  background: var(--color-bg-panel);
}

.mobile-nav-languages {
  padding-top: 8px;
}

.mobile-nav-languages .mono-label {
  display: block;
  padding: 8px 14px;
}

.nav-veil {
  position: fixed;
  inset: var(--header-height) 0 0;
  z-index: 90;
  display: none;
  border: 0;
  background: color-mix(in srgb, var(--color-black) 76%, transparent);
}

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

.site-footer {
  position: relative;
  overflow-x: clip;
  border-top: 1px solid var(--color-border-soft);
  background: var(--color-bg-panel);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1.2fr .8fr;
  gap: clamp(28px, 5vw, 72px);
  padding-top: 64px;
  padding-bottom: 52px;
}

.footer-brand p {
  max-width: 340px;
  margin-top: 18px;
  font-size: 14px;
}

.footer-heading {
  margin-bottom: 17px;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.footer-links {
  display: grid;
  gap: 10px;
}

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

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

.footer-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-keywords a {
  max-width: 100%;
}

.footer-bottom {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--color-border-soft);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

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

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

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

.tilt,
.tilt-card {
  transform: rotate(-.25deg);
}

.prose {
  min-width: 0;
  color: var(--color-text-muted);
}

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

.prose p,
.prose li {
  overflow-wrap: break-word;
}

.prose a:not(.button) {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--color-accent) 42%, transparent);
  text-underline-offset: 3px;
}

.prose ul,
.prose ol {
  padding-left: 1.25em;
}

.prose li + li {
  margin-top: .5em;
}

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

@keyframes title-scan {
  0%,
  35%,
  100% {
    background-position: 100% 50%;
  }
  55%,
  75% {
    background-position: 0 50%;
  }
}

@media (max-width: 1120px) {
  .desktop-nav {
    font-size: 12px;
  }

  .desktop-nav a + a::before {
    margin: 0 6px;
  }

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

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: auto 1fr auto;
  }

  .desktop-nav {
    display: none;
  }

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

  .language-switch {
    display: none;
  }

  .menu-toggle {
    display: grid;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 68px;
    --toc-offset: 82px;
  }

  h1,
  .hero-title {
    font-size: clamp(32px, 9vw, 40px);
    line-height: 1.13;
    letter-spacing: -.018em;
  }

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

  .site-header {
    min-height: var(--header-height);
    gap: 10px;
  }

  .brand-local {
    display: none;
  }

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

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

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 20px;
    padding-bottom: 20px;
  }
}

@media (max-width: 640px) {
  .wrap,
  .reading-wrap {
    padding-inline: max(16px, var(--gutter));
  }

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

  .button-row {
    width: 100%;
  }

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

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

  .panel {
    padding: 20px;
  }
}

@media (max-width: 390px) {
  .site-brand {
    font-size: 16px;
  }

  .site-brand img {
    width: 28px;
    height: 28px;
  }

  .header-tools {
    gap: 5px;
  }

  .login-button {
    min-width: 54px;
    padding-inline: 11px;
  }
}

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

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

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