:root {
  --brand: #0f766e;
  --brand2: #0369a1;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  background:
    radial-gradient(1100px 620px at 12% 4%, rgba(15, 118, 110, 0.2), transparent 66%),
    radial-gradient(900px 560px at 86% -2%, rgba(3, 105, 161, 0.2), transparent 62%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}

.wrap {
  padding: clamp(16px, 3.6vw, 32px) clamp(14px, 3vw, 20px) clamp(34px, 5vw, 60px);
}

h1 {
  letter-spacing: -0.015em;
}

.top,
.card {
  border-width: 1.5px;
}

.top {
  border-radius: 22px;
  background: rgba(15, 26, 51, 0.6);
}

.card {
  border-radius: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.toc {
  border-left: 3px solid rgba(96, 165, 250, 0.4);
}

.toc a {
  padding: 10px 12px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.toc a.is-active {
  color: var(--text);
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(96, 165, 250, 0.14);
}

.btn:hover {
  background-color: rgba(96, 165, 250, 0.12);
}

.btn,
.toc a {
  min-height: 44px;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible,
.toc a:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.28);
}

pre {
  font-size: clamp(12px, 2.5vw, 14px);
  line-height: 1.5;
  border-color: rgba(148, 163, 184, 0.35);
}

.refs a {
  display: inline-block;
  padding: 4px 0;
}

.callout {
  position: relative;
  padding-left: 40px;
  border-left: 4px solid rgba(15, 118, 110, 0.68);
}

.callout::before {
  content: "i";
  position: absolute;
  top: 10px;
  left: 12px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  background: rgba(96, 165, 250, 0.8);
}

.callout.warn {
  border-left-color: rgba(217, 119, 6, 0.7);
}

.callout.warn::before {
  content: "!";
  background: rgba(251, 191, 36, 0.86);
}

.callout.bad {
  border-left-color: rgba(225, 29, 72, 0.75);
}

.callout.bad::before {
  content: "!";
  background: rgba(251, 113, 133, 0.88);
}

.tblWrap th,
.tblWrap td {
  padding: 12px 14px;
}

.tblWrap th {
  background: rgba(96, 165, 250, 0.08);
}

.tblWrap tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.section-anchor {
  margin-left: 8px;
  font-size: 0.85em;
  opacity: 0;
  text-decoration: none;
  border-bottom: none;
  transition: opacity 0.2s ease;
}

h2:hover .section-anchor,
h3:hover .section-anchor,
h2:focus-within .section-anchor,
h3:focus-within .section-anchor {
  opacity: 0.85;
}

.refs a[href^="http"]::after {
  content: " ↗";
  font-size: 0.82em;
}

.backToTop {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 12px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.18);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.backToTop.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.btn:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (min-width: 920px) {
  .toc {
    position: sticky;
    top: 20px;
    align-self: start;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --line: rgba(15, 23, 42, 0.18);
  }

  .top {
    background: rgba(255, 255, 255, 0.92);
  }

  .tblWrap tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.03);
  }
}

@media (max-width: 480px) {
  .top,
  .card {
    border-radius: 14px;
  }

  .backToTop {
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 640px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .meta {
    min-width: 0;
    width: 100%;
  }

  .metaRow {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .metaRow strong {
    white-space: normal;
    word-break: break-word;
  }

  .btnRow .btn {
    width: 100%;
    justify-content: center;
  }

  .toc a {
    color: var(--text);
    opacity: 0.88;
  }

  pre {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .section-anchor {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .top {
    animation: explainer-enter-down 0.45s ease both;
  }

  .card {
    animation: explainer-enter-up 0.45s ease both;
  }

  .grid > .card:nth-child(1) {
    animation-delay: 0.06s;
  }

  .grid > .card:nth-child(2) {
    animation-delay: 0.1s;
  }

  @keyframes explainer-enter-up {
    from {
      opacity: 0;
      transform: translateY(8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes explainer-enter-down {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
