*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --sidebar-bg: #0f1419;
  --sidebar-text: #c8d0da;
  --sidebar-muted: #6b7785;
  --sidebar-accent: #3dd6c6;
  --sidebar-active: rgba(61, 214, 198, 0.12);
  --content-bg: #f4f1eb;
  --content-text: #1a1f26;
  --content-muted: #5c6570;
  --border: rgba(26, 31, 38, 0.08);
  --sidebar-width: 300px;
  --font-sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.65;
  color: var(--content-text);
  background: var(--content-bg);
}

body.menu-open {
  overflow: hidden;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.25rem;
  background:
    linear-gradient(165deg, rgba(61, 214, 198, 0.06) 0%, transparent 45%),
    var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
}

.sidebar__header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__label {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sidebar-accent);
}

.sidebar__title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.25;
  color: #eef2f6;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar__link {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--sidebar-text);
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #eef2f6;
}

.sidebar__link--active {
  background: var(--sidebar-active);
  color: #eef2f6;
}

.sidebar__link-index {
  flex-shrink: 0;
  width: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--sidebar-accent);
  opacity: 0.85;
}

.sidebar__link-text {
  font-size: 0.92rem;
  line-height: 1.45;
}

.sidebar__toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 110;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--sidebar-bg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.sidebar__toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  background: #eef2f6;
  border-radius: 1px;
}

.sidebar-overlay {
  display: none;
}

.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.article {
  max-width: 820px;
  margin: 0 auto;
  padding: 4rem 2.5rem 6rem;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article__header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.article__meta {
  margin: 0 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--content-muted);
}

.article__title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--content-text);
}

.article__body p {
  margin: 0 0 1.25rem;
}

.article__body p:last-child {
  margin-bottom: 0;
}

.article__body .lead {
  font-size: 1.15rem;
  color: var(--content-muted);
}

.article__body h3 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.35;
}

.article__body h4 {
  margin: 2rem 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.article__body h5 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.article__body ul,
.article__body ol {
  margin: 0 0 1.25rem;
  padding-left: 1.35rem;
}

.article__body li {
  margin-bottom: 0.45rem;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
  padding: 1rem 1.1rem;
  background: rgba(26, 31, 38, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.toc__link {
  padding: 0.35rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-decoration: none;
  color: var(--content-text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.2s, color 0.2s;
}

.toc__link:hover {
  border-color: var(--sidebar-accent);
  color: #0d7a70;
}

.task {
  margin-bottom: 3.5rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.task:last-of-type {
  border-bottom: none;
}

.task__label {
  display: inline-block;
  margin-bottom: 0.65rem;
  padding: 0.25rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0d7a70;
  background: rgba(61, 214, 198, 0.15);
  border-radius: 4px;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--content-muted);
  background: rgba(26, 31, 38, 0.03);
}

.art-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 1rem;
}

.art-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.25rem;
  padding: 1.1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.art-card__figure {
  margin: 0;
}

.art-card__figure img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  background: #e8e4dc;
}

.art-card__figure img.is-error,
.inline-figure img.is-error {
  object-fit: contain;
  padding: 1rem;
  background: #e8e4dc;
  color: var(--content-muted);
  font-size: 0.75rem;
}

.art-card__figure figcaption {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--content-muted);
}

.placeholder-art {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 160px;
  background: #1a1f26;
  border-radius: 8px;
  color: #3dd6c6;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.placeholder-art code {
  margin-top: 0.5rem;
  color: #8899a6;
}

.art-card__body p {
  font-size: 0.92rem;
}

.tag {
  display: inline-block;
  margin: 0 0.35rem 0.5rem 0;
  padding: 0.15rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #0d7a70;
  background: rgba(61, 214, 198, 0.12);
  border-radius: 4px;
}

.tag--alt {
  color: #6b4fa0;
  background: rgba(107, 79, 160, 0.1);
}

.art-card__link {
  display: inline-block;
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-decoration: none;
  color: #0d7a70;
}

.art-card__link:hover {
  text-decoration: underline;
}

.conclusion {
  margin-top: 1.75rem;
  padding: 1.25rem 1.35rem;
  background: rgba(61, 214, 198, 0.08);
  border-left: 3px solid var(--sidebar-accent);
  border-radius: 0 8px 8px 0;
}

.conclusion h4 {
  margin-top: 0;
}

.info-box {
  margin: 1.25rem 0 1.75rem;
  padding: 1rem 1.2rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.info-box--warn {
  background: rgba(200, 120, 40, 0.1);
  border: 1px solid rgba(200, 120, 40, 0.25);
}

.styled-list li {
  margin-bottom: 0.65rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.compare-card {
  padding: 1.1rem 1.2rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

.compare-card h5 {
  margin: 0 0 0.65rem;
}

.compare-card ul {
  margin: 0;
  padding-left: 1.1rem;
}

.compare-card--good {
  background: rgba(61, 214, 198, 0.1);
  border: 1px solid rgba(61, 214, 198, 0.25);
}

.compare-card--bad {
  background: rgba(200, 80, 60, 0.08);
  border: 1px solid rgba(200, 80, 60, 0.2);
}

.inline-figure {
  margin: 1.75rem 0;
}

.inline-figure img {
  display: block;
  width: 100%;
  border-radius: 10px;
  background: #e8e4dc;
}

.inline-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--content-muted);
}

.sources {
  margin-top: 1rem;
}

.sources-list {
  font-size: 0.88rem;
}

.sources-list a {
  color: #0d7a70;
  word-break: break-word;
}

.sketch-block {
  margin: 1.25rem 0 1.5rem;
}

.sketch-block__canvas {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.sketch-block__canvas--wide {
  max-width: 100%;
}

.sketch-block__canvas--short canvas {
  max-width: 100%;
}

.sketch-block__caption {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--content-muted);
  text-align: center;
}

.demo-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 1rem 0 1.5rem;
}

.code-details {
  margin: 1rem 0 1.5rem;
}

.code-details summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--content-muted);
  margin-bottom: 0.5rem;
}

.code-block {
  margin: 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: #e8ecf0;
  background: #1a1f26;
  border-radius: 8px;
}

.code-block--sm {
  font-size: 0.72rem;
  padding: 0.65rem 0.85rem;
}

.code-block code {
  white-space: pre;
}

.article__note {
  margin: 0 0 2rem;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  color: var(--content-muted);
  background: rgba(61, 214, 198, 0.1);
  border-left: 3px solid var(--sidebar-accent);
  border-radius: 0 6px 6px 0;
}

.article__note kbd {
  padding: 0.1rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: rgba(26, 31, 38, 0.08);
  border-radius: 3px;
}

.api-panel,
.weather-panel {
  margin: 1.25rem 0 1.5rem;
  padding: 1.25rem 1.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(26, 31, 38, 0.04);
}

.api-panel__label {
  margin: 0 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0d7a70;
}

.api-panel__output {
  margin: 0;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: #e8ecf0;
  background: #1a1f26;
  border-radius: 8px;
}

.api-panel__list {
  margin: 0;
  padding-left: 1.25rem;
  max-height: 320px;
  overflow-y: auto;
}

.api-panel__list li {
  margin-bottom: 0.65rem;
  padding-left: 0.25rem;
}

.api-panel__status,
.api-panel__error {
  margin: 0;
}

.api-panel__error {
  color: #b42318;
}

.weather-panel__city {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.weather-panel__temp {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 500;
  color: #0d7a70;
}

.weather-panel__desc {
  margin: 0.25rem 0 0.75rem;
  text-transform: capitalize;
  color: var(--content-muted);
}

.weather-panel__details {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.95rem;
  color: var(--content-muted);
}

.weather-panel__status,
.weather-panel__error {
  margin: 0;
}

.weather-panel__error {
  color: #b42318;
}

@media (max-width: 700px) {
  .demo-pair {
    grid-template-columns: 1fr;
  }

  .art-card {
    grid-template-columns: 1fr;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.25);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar__toggle {
    display: block;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(15, 20, 25, 0.55);
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay[hidden] {
    display: none;
  }

  .content {
    margin-left: 0;
  }

  .article {
    padding: 5rem 1.25rem 4rem;
  }
}
