:root {
    --bg: #0a0a14;
    --text: #f4f4f7;
    --muted: #9ea0b3;
    --card: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.08);
    --red-1: #a82828;
    --red-2: #5c0000;
    --doc-bg: #ffffff;
    --doc-text: #1a1a2e;
    --doc-muted: #5c5c72;
    --doc-border: #e2e4ec;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; }
  body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg); color: var(--text);
    line-height: 1.65; min-height: 100vh;
    display: flex; flex-direction: column;
    overflow-x: hidden; -webkit-font-smoothing: antialiased;
  }

  body::before {
    content: ""; position: fixed; top: -20%; left: -10%;
    width: 60vw; height: 60vw;
    background: radial-gradient(circle, rgba(168,40,40,0.35), transparent 60%);
    filter: blur(80px); z-index: -1;
    animation: float 18s ease-in-out infinite;
  }
  body::after {
    content: ""; position: fixed; bottom: -20%; right: -10%;
    width: 60vw; height: 60vw;
    background: radial-gradient(circle, rgba(168,40,40,0.35), transparent 60%);
    filter: blur(80px); z-index: -1;
    animation: float 18s ease-in-out infinite reverse;
  }
  @keyframes float {
    0%, 100% { transform: translate(0,0) scale(1); }
    50% { transform: translate(40px,-30px) scale(1.1); }
  }

  .container { max-width: 1180px; margin: 0 auto; padding: 0 24px; width: 100%; }
  .doc-inner { max-width: 1032px; }

  header {
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    background: rgba(10,10,20,0.6); border-bottom: 1px solid var(--border);
  }
  nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; gap: 16px; }
  .logo {
    font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.5rem;
    letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: inherit;
  }
  .logo-mark {
    width: 44px; height: 38px; display: block;
    filter: drop-shadow(0 8px 18px rgba(168,40,40,0.5));
    transition: transform 0.25s ease;
  }
  .logo:hover .logo-mark { transform: rotate(-4deg) scale(1.05); }
  .logo span { background: linear-gradient(135deg, #fff, #ffc5b9); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .nav-menu { display: flex; gap: 28px; list-style: none; margin: 0 auto; }
  .nav-menu li a {
    color: var(--muted); font-size: 0.95rem; font-weight: 500;
    letter-spacing: 0.01em; text-decoration: none; transition: color 0.2s; padding-bottom: 2px;
  }
  .nav-menu li a:hover { color: var(--text); }
  .nav-menu li a.active { color: var(--text); border-bottom: 1px solid rgba(168,40,40,0.7); }
  .nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }
  .nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    cursor: pointer;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
  }
  .nav-toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
  }
  header.nav-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  header.nav-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
  header.nav-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
  @media (max-width: 760px) {
    nav { position: relative; flex-wrap: wrap; }
    .nav-toggle { display: flex; }
    .nav-menu {
      display: none;
      flex-direction: column;
      gap: 0;
      width: 100%;
      order: 10;
      margin: 0;
      padding: 8px 0 12px;
      border-top: 1px solid var(--border);
    }
    header.nav-open .nav-menu { display: flex; }
    .nav-menu li a {
      display: block;
      padding: 14px 4px;
      font-size: 1rem;
    }
    .nav-menu li a.active { border-bottom: 0; color: var(--text); }
  }
.lang-switch {
    display: inline-flex; background: var(--card);
    border: 1px solid var(--border); border-radius: 999px; padding: 4px; gap: 2px;
  }
  .lang-switch button {
    background: transparent; border: 0; color: var(--muted);
    font-family: inherit; font-weight: 600; font-size: 0.8rem;
    padding: 6px 12px; border-radius: 999px; cursor: pointer;
    transition: all 0.2s; letter-spacing: 0.05em;
  }
  .lang-switch button:hover { color: var(--text); }
  .lang-switch button.active {
    background: linear-gradient(135deg, var(--red-1), var(--red-2));
    color: white; box-shadow: 0 4px 14px rgba(168,40,40,0.5);
  }

  main { flex: 1; display: flex; flex-direction: column; }

  .doc-sheet {
    flex: 1;
    background: var(--doc-bg);
    color: var(--doc-text);
    padding: 36px 0 56px;
    box-shadow: 0 -1px 0 var(--doc-border);
  }

  .doc-sheet h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.7rem, 4.6vw, 3rem);
    line-height: 1.15; letter-spacing: -0.03em; font-weight: 700;
    margin-bottom: 12px; color: var(--doc-text);
  }
  .doc-intro { color: var(--doc-muted); font-size: 0.95rem; margin-bottom: 8px; }

  .back-link {
    display: inline-block; margin-bottom: 24px;
    color: var(--red-1); font-size: 0.9rem; font-weight: 500; text-decoration: none;
  }
  .back-link:hover { color: var(--red-2); text-decoration: underline; }

  .diagram-inline {
    float: right;
    width: min(42%, 280px);
    margin: 4px 0 14px 22px;
    background: #f6f7fb;
    border: 1px solid var(--doc-border);
    border-radius: 12px;
    padding: 10px;
  }
  .diagram-inline a { display: block; line-height: 0; }
  .diagram-inline img {
    display: block; width: 100%; height: auto;
    border-radius: 8px; cursor: zoom-in;
    border: 1px solid var(--doc-border);
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .diagram-inline a:hover img {
    border-color: rgba(168,40,40,0.45);
    box-shadow: 0 6px 20px rgba(26,26,46,0.1);
  }
  .diagram-inline figcaption {
    font-size: 0.72rem; color: var(--doc-muted);
    margin-top: 8px; line-height: 1.35; text-align: center;
  }
  @media (max-width: 640px) {
    .diagram-inline {
      float: none; width: 100%; max-width: 280px;
      margin: 0 auto 18px;
    }
  }
  .doc-body .clear-float { clear: both; }

  [data-lang-block] { display: none; }
  [data-lang-block].lang-active { display: block; }

  .doc-body h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em;
    margin: 40px 0 16px; padding-top: 8px;
    border-top: 1px solid var(--doc-border); color: var(--doc-text);
  }
  .doc-body h2:first-of-type { border-top: 0; margin-top: 0; }
  .doc-body h3 {
    font-size: 1.05rem; font-weight: 600; margin: 24px 0 10px; color: var(--red-1);
  }
  .doc-body p { margin-bottom: 14px; color: #333348; }
  .doc-body ul, .doc-body ol { margin: 0 0 16px 1.25rem; color: #333348; }
  .doc-body li { margin-bottom: 8px; }
  .doc-body strong { color: var(--doc-text); font-weight: 600; }
  .doc-body code {
    font-size: 0.88em; background: #f0f1f6; padding: 2px 6px; border-radius: 4px;
    color: #2d2d44;
  }
  .doc-body table {
    width: 100%; border-collapse: collapse; margin: 16px 0 20px;
    font-size: 0.9rem;
  }
  .doc-body th, .doc-body td {
    border: 1px solid var(--doc-border); padding: 10px 12px; text-align: left;
    color: #333348;
  }
  .doc-body th { background: #f0f1f6; font-weight: 600; color: var(--doc-text); }
  .page-break-label {
    display: inline-block; margin: 32px 0 8px;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--red-1);
    padding: 4px 10px; border-radius: 6px;
    background: rgba(168,40,40,0.08); border: 1px solid rgba(168,40,40,0.22);
  }

  .lightbox {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.92);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; opacity: 0; visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
  }
  .lightbox.open { opacity: 1; visibility: visible; }
  .lightbox img {
    max-width: 100%; max-height: 92vh;
    border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  }
  .lightbox-close {
    position: absolute; top: 20px; right: 24px;
    background: rgba(255,255,255,0.1); border: 0; color: #fff;
    width: 44px; height: 44px; border-radius: 50%;
    font-size: 1.5rem; cursor: pointer; line-height: 1;
  }
  .lightbox-close:hover { background: rgba(255,255,255,0.2); }

  footer {
    border-top: 1px solid var(--border); padding: 20px 0;
    text-align: center; color: var(--muted); font-size: 0.85rem;
    background: var(--bg);
  }
  footer a { color: var(--muted); text-decoration: none; margin: 0 8px; transition: color 0.2s; }
  footer a:hover { color: var(--text); }
