:root {
  --color-bg: #fffdf7;
  --color-panel: #f8f4e9;
  --color-panel-strong: #eee8d9;
  --color-border: #d8d1c0;
  --color-accent: #dfa62a;
  --color-accent-dark: #a96f08;
  --color-text: #123b3a;
  --color-text-muted: #607270;
  --color-success: #287565;
  --color-warning: #a96f08;
  --color-error: #a34e3f;
  --color-white: #ffffff;
  --color-transparent: transparent;
  --color-grid: rgba(18, 59, 58, 0.075);
  --color-text-soft: rgba(18, 59, 58, 0.62);
  --color-accent-soft: rgba(223, 166, 42, 0.13);
  --color-accent-glow: rgba(223, 166, 42, 0.24);
  --color-panel-glass: rgba(255, 253, 247, 0.9);
  --color-panel-solid: rgba(248, 244, 233, 1);
  --color-overlay: rgba(18, 59, 58, 0.28);
  --color-focus: rgba(223, 166, 42, 0.48);
  --flag-red: #b7463f;
  --flag-red-bright: #d95850;
  --flag-blue: #315a82;
  --flag-blue-soft: #527ba3;
  --flag-white: #ffffff;
  --flag-black: #173231;

  --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", ui-monospace, SFMono-Regular, Consolas, monospace;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --border-hairline: 1px;
  --header-height: 74px;
  --page-width: 1320px;
  --reading-width: 48rem;
  --gutter: clamp(16px, 3vw, 32px);
  --section-space: clamp(64px, 9vw, 120px);
  --shadow-button: 0 8px 22px rgba(169, 111, 8, 0.16);
  --transition-fast: 180ms ease;
  --transition-slow: 560ms cubic-bezier(0.22, 1, 0.36, 1);
  --toc-top: calc(var(--header-height) + 10px);
  --toc-clearance: calc(var(--header-height) + 84px);
}

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

html {
  min-width: 320px;
  overflow-x: clip;
  scroll-behavior: smooth;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}

html.nav-open {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  background:
    linear-gradient(var(--color-grid) var(--border-hairline), var(--color-transparent) var(--border-hairline)),
    linear-gradient(90deg, var(--color-grid) var(--border-hairline), var(--color-transparent) var(--border-hairline)),
    var(--color-bg);
  background-size: 48px 48px;
  font-size: 16px;
  line-height: 1.7;
}

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

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

img {
  height: auto;
}

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

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

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

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

p {
  margin-bottom: 1.15em;
}

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

li + li {
  margin-top: 0.42em;
}

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

:not(pre) > code {
  padding: 0.12em 0.38em;
  border: var(--border-hairline) solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--color-panel);
  overflow-wrap: anywhere;
}

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

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

table {
  border-collapse: collapse;
}

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

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

.wrap {
  width: 100%;
  max-width: calc(var(--page-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-compact {
  padding-top: calc(var(--section-space) * 0.58);
  padding-bottom: calc(var(--section-space) * 0.58);
}

.section-heading {
  max-width: 760px;
  margin-bottom: 36px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--color-accent-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1,
.hero-title {
  margin-bottom: 18px;
  font-size: clamp(52px, 4.72vw, 68px);
  font-weight: 820;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 18px;
  font-size: clamp(34px, 4vw, 50px);
  line-height: 1.16;
  letter-spacing: -0.018em;
}

h3 {
  margin-bottom: 12px;
  font-size: clamp(22px, 2.4vw, 29px);
  line-height: 1.3;
}

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

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

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

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

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

.eyebrow,
.badge,
.tag {
  max-width: 100%;
  overflow: hidden;
  border: var(--border-hairline) solid var(--color-border);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
  background: var(--color-panel-glass);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.eyebrow {
  min-height: 30px;
  padding: 0 13px;
  text-transform: uppercase;
}

.badge,
.tag {
  min-height: 28px;
  padding: 0 10px;
}

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

.status-dot,
.eyebrow-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
}

.status-dot-success {
  background: var(--color-success);
}

.button {
  min-width: 136px;
  min-height: 46px;
  padding: 0 22px;
  border: var(--border-hairline) solid var(--color-text);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.2;
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    color var(--transition-fast),
    background-color var(--transition-fast),
    border-color var(--transition-fast);
}

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

.button-primary {
  border-color: var(--color-text);
  color: var(--color-bg);
  background: var(--color-text);
  box-shadow: var(--shadow-button);
}

.button-primary:hover {
  background: var(--color-success);
}

.button-secondary {
  background: var(--color-panel-glass);
}

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

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

.button-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

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

.panel,
.card {
  border: var(--border-hairline) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-panel-glass);
}

.panel {
  padding: clamp(20px, 3vw, 34px);
}

.card {
  padding: 22px;
}

.engineering-panel {
  position: relative;
}

.engineering-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  width: 42px;
  border-top: 3px solid var(--color-accent);
}

.site-header {
  height: var(--header-height);
  border-bottom: var(--border-hairline) solid var(--color-border);
  background: var(--color-panel-glass);
  position: relative;
  z-index: 50;
}

.header-inner {
  width: min(calc(100% - 40px), var(--page-width));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.brand-logo {
  width: 42px;
  height: 34px;
  object-fit: contain;
}

.brand-word {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-local {
  padding-left: 9px;
  border-left: var(--border-hairline) solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 550;
  letter-spacing: 0.04em;
}

.desktop-nav {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.nav-link {
  min-height: 38px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 570;
  white-space: nowrap;
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast);
}

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

.nav-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

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

.login-link {
  min-height: 40px;
  padding: 0 17px;
  border: var(--border-hairline) solid var(--color-text);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast);
}

.login-link:hover {
  color: var(--color-bg);
  background: var(--color-text);
}

.language-menu {
  position: relative;
}

.language-button,
.menu-toggle {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  background: var(--color-transparent);
  cursor: pointer;
}

.language-button {
  padding: 0 11px;
  white-space: nowrap;
}

.language-dropdown {
  min-width: 156px;
  padding: 7px;
  border: var(--border-hairline) solid var(--color-border);
  border-radius: var(--radius-sm);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  background: var(--color-bg);
}

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

.language-dropdown a {
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

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

.menu-toggle {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

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

.mobile-drawer {
  display: none;
}

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

.mobile-drawer {
  width: 100%;
  max-height: calc(100dvh - var(--header-height));
  padding: 10px var(--gutter) 20px;
  border-top: var(--border-hairline) solid var(--color-border);
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 53;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-panel-solid);
}

.mobile-drawer a {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-bottom: var(--border-hairline) solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-language-list {
  padding-top: 10px;
}

.mobile-language-list a {
  color: var(--color-text-muted);
}

.nav-veil {
  position: fixed;
  inset: var(--header-height) 0 0;
  z-index: 40;
  display: none;
  background: var(--color-overlay);
}

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

.site-footer {
  border-top: var(--border-hairline) solid var(--color-border);
  background: var(--color-panel);
}

.footer-main {
  padding-top: 64px;
  padding-bottom: 48px;
  display: grid;
  grid-template-columns: minmax(250px, 1.15fr) repeat(3, minmax(150px, 1fr));
  gap: 42px;
}

.footer-brand .brand {
  margin-bottom: 18px;
}

.footer-brand p {
  max-width: 360px;
  color: var(--color-text-muted);
}

.footer-heading {
  margin: 0 0 15px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.footer-links a {
  width: fit-content;
  color: var(--color-text-muted);
  font-size: 14px;
}

.footer-links a:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-underline-offset: 4px;
}

.footer-bottom {
  min-height: 72px;
  padding-top: 18px;
  padding-bottom: 18px;
  border-top: var(--border-hairline) solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.footer-legal,
.footer-languages {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

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

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

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

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

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

@media (max-width: 1180px) {
  .header-inner {
    gap: 10px;
  }

  .brand-local,
  .desktop-nav .nav-icon {
    display: none;
  }

  .nav-link {
    padding-inline: 6px;
    font-size: 12px;
  }

  .language-button {
    display: none;
  }
}

@media (max-width: 900px) {
  :root {
    --header-height: 64px;
  }

  .desktop-nav {
    display: none;
  }

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

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

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

  h1,
  .hero-title {
    font-size: clamp(34px, 7vw, 40px);
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .header-inner {
    width: 100%;
    padding-inline: var(--gutter);
  }

  .brand-logo {
    width: 36px;
  }

  .brand-local {
    display: inline;
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .login-link {
    min-height: 36px;
    padding-inline: 13px;
  }

  .button-row,
  .button {
    width: 100%;
  }

  .title-lock {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .eyebrow,
  .badge,
  .tag {
    white-space: normal;
  }

  .footer-main {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .decorative-orbit,
  .decorative-disc,
  .decorative-glow,
  .watermark {
    max-width: 100%;
  }
}

@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;
    transform: none;
  }
}