:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0a0a0f;
  --page-glow: rgba(99, 102, 241, 0.14);
  --surface: #151821;
  --surface-muted: #1d212c;
  --text-primary: #f4f5f7;
  --text-secondary: #aeb5c2;
  --text-muted: #8f98a8;
  --border: #292e3c;
  --image-border: #303646;
  --header-strip: #252936;
  --accent: #ffdc00;
  --accent-ink: #17191c;
  --link: #ffe34f;
  --eyebrow: #e3c83f;
  --tag-text: #f5da46;
  --tag-bg: rgba(255, 220, 0, 0.1);
  --tag-border: rgba(255, 220, 0, 0.2);
  --surface-shadow: rgba(0, 0, 0, 0.28);
  --image-shadow: rgba(0, 0, 0, 0.24);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--page-bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

html[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f7f8fc;
  --page-glow: rgba(79, 70, 229, 0.08);
  --surface: #ffffff;
  --surface-muted: #eef1f5;
  --text-primary: #17191c;
  --text-secondary: #555d68;
  --text-muted: #69727f;
  --border: #d8dee8;
  --image-border: #d8dee8;
  --header-strip: #17191c;
  --accent: #ffdc00;
  --accent-ink: #17191c;
  --link: #675700;
  --eyebrow: #6d6200;
  --tag-text: #5f5000;
  --tag-bg: #fff6b5;
  --tag-border: rgba(85, 72, 0, 0.14);
  --surface-shadow: rgba(23, 25, 28, 0.08);
  --image-shadow: rgba(23, 25, 28, 0.12);
}

html {
  background: var(--page-bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 50% -12rem, var(--page-glow), transparent 42rem),
    var(--page-bg);
  color: var(--text-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
}

.site-header,
.site-footer {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header {
  min-height: 72px;
  border-top: 8px solid var(--header-strip);
}

.site-header::before {
  content: "";
  position: absolute;
  top: 0;
  width: 84px;
  height: 8px;
  background: var(--accent);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.site-header a,
.site-footer a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--accent-ink);
  background: var(--accent);
}

.article-layout,
.library-layout,
.not-found {
  width: min(960px, calc(100% - 40px));
  margin: 52px auto 96px;
}

.article-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.article-topline > a {
  text-decoration: none;
}

.article-topline > a::before {
  content: "← ";
}

.article-tags,
.library-card__meta > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.article-tags span,
.library-card__meta span {
  padding: 5px 9px;
  border: 1px solid var(--tag-border);
  border-radius: 999px;
  color: var(--tag-text);
  background: var(--tag-bg);
  font-size: 12px;
  font-weight: 700;
}

.article-content {
  padding: clamp(28px, 6vw, 72px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 18px 60px var(--surface-shadow);
}

.article-content h1 {
  max-width: 760px;
  margin: 0 0 32px;
  font-size: clamp(38px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.article-content h1::after {
  content: "";
  display: block;
  width: 96px;
  height: 6px;
  margin-top: 28px;
  border-radius: 4px;
  background: var(--accent);
}

.article-content h2 {
  margin: 64px 0 22px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.article-content h3 {
  margin: 42px 0 16px;
  font-size: 24px;
  line-height: 1.2;
}

.article-content p,
.article-content li {
  font-size: 18px;
  line-height: 1.72;
}

.article-content p {
  margin: 0 0 22px;
}

.article-content img {
  display: block;
  width: calc(100% + 48px);
  max-width: none;
  height: auto;
  margin: 38px -24px;
  border: 1px solid var(--image-border);
  border-radius: 18px;
  box-shadow: 0 12px 36px var(--image-shadow);
}

.article-content blockquote {
  margin: 36px 0;
  padding: 24px 28px;
  border-left: 6px solid var(--accent);
  background: var(--surface-muted);
}

.article-content blockquote p {
  margin: 0;
  font-size: 21px;
  font-weight: 750;
  line-height: 1.45;
}

.article-content hr {
  margin: 64px 0 28px;
  border: 0;
  border-top: 1px solid var(--image-border);
}

.article-source {
  display: flex;
  justify-content: flex-end;
  padding: 24px 4px 0;
}

.source-link,
.library-card__link {
  display: inline-flex;
  padding: 11px 15px;
  border-radius: 8px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 750;
  text-decoration: none;
}

.library-hero {
  padding: 44px 0 50px;
}

.eyebrow {
  color: var(--eyebrow);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.library-hero h1,
.not-found h1 {
  margin: 14px 0;
  font-size: clamp(48px, 8vw, 80px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.library-hero p,
.not-found p {
  max-width: 660px;
  color: var(--text-secondary);
  font-size: 19px;
  line-height: 1.6;
}

.library-grid {
  display: grid;
  gap: 20px;
}

.library-card {
  padding: clamp(26px, 5vw, 44px);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 16px 50px var(--surface-shadow);
}

.library-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.library-card h2 {
  max-width: 760px;
  margin: 24px 0 14px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
}

.library-card h2 a {
  color: var(--text-primary);
  text-decoration: none;
}

.library-card p {
  max-width: 700px;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.65;
}

.library-card__link {
  margin-top: 10px;
}

.not-found {
  min-height: 60vh;
  display: grid;
  align-content: center;
}

.site-footer {
  min-height: 84px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

.theme-toggle {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.theme-toggle__icon {
  width: 15px;
  color: var(--link);
  font-size: 15px;
  line-height: 1;
  text-align: center;
}

@media (max-width: 700px) {
  .site-header,
  .site-footer,
  .article-layout,
  .library-layout,
  .not-found {
    width: min(100% - 28px, 960px);
  }

  .article-layout,
  .library-layout {
    margin-top: 28px;
  }

  .article-topline,
  .library-card__meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .article-content {
    padding: 24px 20px 42px;
    border-radius: 16px;
  }

  .article-content img {
    width: 100%;
    margin: 28px 0;
    border-radius: 10px;
  }

  .article-content p,
  .article-content li {
    font-size: 17px;
  }

  .site-header nav {
    gap: 12px;
  }

  .theme-toggle {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .theme-toggle__label {
    display: none;
  }
}

@media print {
  body,
  .article-content {
    background: #fff;
    color: #17191c;
  }

  a {
    color: #554800;
  }

  .site-header,
  .site-footer,
  .article-topline,
  .article-source {
    display: none;
  }

  .article-layout {
    width: 100%;
    margin: 0;
  }

  .article-content {
    padding: 0;
    box-shadow: none;
  }

  .article-content img,
  .article-content blockquote {
    break-inside: avoid;
  }
}
