:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #1b1d22;
  --surface-2: #23262d;
  --surface-3: #292c34;
  --header: rgba(16, 17, 20, .88);
  --footer: #0d0e11;
  --border: #343842;
  --border-soft: #2b2e36;
  --text: #f4f5f7;
  --text-soft: #d9dbe1;
  --muted: #a9aeba;
  --muted-2: #7f8591;
  --brand: #7c84ff;
  --brand-strong: #5865f2;
  --brand-soft: rgba(124, 132, 255, .14);
  --link: #aeb4ff;
  --green: #57f287;
  --red: #ed4245;
  --code: #121418;
  --input: #15171b;
  --shadow: 0 22px 64px rgba(0, 0, 0, .3);
  --glow: rgba(88, 101, 242, .2);
  --max: 1120px;
  --article: 760px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e9edf5;
  --header: rgba(250, 251, 254, .92);
  --footer: #e9edf5;
  --border: #d8deea;
  --border-soft: #e4e8f0;
  --text: #1d2430;
  --text-soft: #354052;
  --muted: #5e6878;
  --muted-2: #788397;
  --brand: #5865f2;
  --brand-strong: #4d5be7;
  --brand-soft: rgba(88, 101, 242, .1);
  --link: #4050cf;
  --green: #168a45;
  --red: #c9333b;
  --code: #f4f6fa;
  --input: #ffffff;
  --shadow: 0 22px 64px rgba(40, 51, 76, .13);
  --glow: rgba(88, 101, 242, .12);
}

html[data-theme="ocean"] {
  color-scheme: dark;
  --bg: #07171b;
  --surface: #10282e;
  --surface-2: #153139;
  --surface-3: #1b3b44;
  --header: rgba(7, 23, 27, .9);
  --footer: #041014;
  --border: #28505a;
  --border-soft: #1d4048;
  --text: #eefbfc;
  --text-soft: #d7ecef;
  --muted: #9bbbc0;
  --muted-2: #73969d;
  --brand: #45c8d8;
  --brand-strong: #1596aa;
  --brand-soft: rgba(69, 200, 216, .14);
  --link: #7edce7;
  --green: #64e6a5;
  --code: #07191d;
  --input: #07191d;
  --glow: rgba(21, 150, 170, .22);
}

html[data-theme="sunset"] {
  color-scheme: dark;
  --bg: #1a0f16;
  --surface: #2b1822;
  --surface-2: #35202b;
  --surface-3: #412735;
  --header: rgba(26, 15, 22, .9);
  --footer: #10080d;
  --border: #5a3548;
  --border-soft: #462a39;
  --text: #fff5f8;
  --text-soft: #f2dbe3;
  --muted: #cfadb9;
  --muted-2: #a98290;
  --brand: #ff8b8b;
  --brand-strong: #df5d73;
  --brand-soft: rgba(255, 139, 139, .14);
  --link: #ffb3bc;
  --green: #8ee6ad;
  --code: #180d13;
  --input: #180d13;
  --glow: rgba(223, 93, 115, .23);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% -6%, var(--glow), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: var(--link);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  transform: translateY(-140%);
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  padding: 9px 13px;
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 70%, white);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  z-index: 40;
  top: 0;
  border-bottom: 1px solid var(--border-soft);
  background: var(--header);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.header-inner {
  width: min(calc(100% - 32px), var(--max));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 820;
  letter-spacing: -.025em;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 8px 18px rgba(88, 101, 242, .28));
}

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

.header-nav a {
  border-radius: 9px;
  color: var(--muted);
  padding: 8px 10px;
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
}

.header-nav a:hover,
.header-nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--text);
}

.theme-select {
  width: auto;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--input);
  color: var(--text-soft);
  padding: 6px 30px 6px 10px;
  font-size: .78rem;
  font-weight: 700;
}

.breadcrumbs {
  width: min(calc(100% - 32px), var(--max));
  margin: 24px auto 0;
  color: var(--muted-2);
  font-size: .78rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 6px;
  color: var(--border);
}

.breadcrumbs a {
  color: var(--muted);
}

.article-shell {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, var(--article)) minmax(220px, 1fr);
  justify-content: space-between;
  gap: 56px;
  padding: 44px 0 84px;
}

.article-main {
  min-width: 0;
}

.article-header {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border-soft);
}

.article-kicker,
.blog-kicker {
  margin: 0 0 12px;
  color: var(--brand);
  font-size: .73rem;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.article-header h1,
.blog-hero h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(2.25rem, 6vw, 4.25rem);
  line-height: 1.03;
  letter-spacing: -.055em;
  text-wrap: balance;
}

.article-dek,
.blog-intro {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2.4vw, 1.22rem);
  line-height: 1.58;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 20px;
  color: var(--muted-2);
  font-size: .78rem;
  font-weight: 650;
}

.article-body > section {
  padding-top: 54px;
}

.article-body h2 {
  margin: 0 0 17px;
  font-size: clamp(1.55rem, 3.5vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.article-body h3 {
  margin: 28px 0 7px;
  font-size: 1.08rem;
  line-height: 1.35;
}

.article-body p {
  margin: 0 0 17px;
  color: var(--text-soft);
}

.article-body ul,
.article-body ol {
  margin: 0 0 19px;
  padding-left: 1.35rem;
  color: var(--text-soft);
}

.article-body li + li {
  margin-top: 8px;
}

code {
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  background: var(--code);
  color: var(--text);
  padding: .12em .38em;
  font-family: var(--mono);
  font-size: .87em;
  overflow-wrap: anywhere;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code);
  padding: 16px;
  color: var(--text-soft);
  font: .82rem/1.65 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre code {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.citation {
  display: inline-block;
  margin-left: .16em;
  border-radius: 5px;
  background: var(--brand-soft);
  padding: 0 .38em;
  font-size: .68em;
  font-weight: 800;
  line-height: 1.55;
  text-decoration: none;
  vertical-align: super;
}

.toc {
  position: sticky;
  top: 94px;
  align-self: start;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  padding: 18px;
}

.toc-title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li + li {
  margin-top: 8px;
}

.toc a {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.38;
  text-decoration: none;
}

.toc a:hover {
  color: var(--link);
}

.mini-tool {
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--border));
  border-radius: 18px;
  background:
    linear-gradient(145deg, var(--brand-soft), transparent 45%),
    var(--surface);
  padding: clamp(18px, 4vw, 28px);
  box-shadow: var(--shadow);
}

.mini-tool .tool-intro {
  margin: -8px 0 20px;
  color: var(--muted);
  font-size: .9rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.compact-grid {
  grid-template-columns: minmax(0, 360px);
}

.tool-grid label,
.full-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .025em;
}

.full-label {
  margin-top: 8px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  padding: 9px 11px;
}

input:hover,
select:hover {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.primary-action,
.secondary-action,
.mobile-presets button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 800;
}

.primary-action {
  background: var(--brand-strong);
  color: #fff;
}

.secondary-action,
.mobile-presets button {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
}

.primary-action:hover,
.secondary-action:hover,
.mobile-presets button:hover {
  transform: translateY(-1px);
}

.tool-output {
  min-height: 56px;
  margin: 15px 0 0;
}

.prose-output {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code);
  padding: 14px;
  color: var(--text-soft);
  font-size: .88rem;
}

.prose-output strong {
  color: var(--text);
}

.tool-status,
.code-callout {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.code-callout code {
  font-size: .96em;
}

.mobile-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.result-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text-soft);
  font-size: .84rem;
}

.result-table-wrap table {
  min-width: 600px;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--text);
  font-size: .72rem;
  letter-spacing: .035em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.takeaway {
  border-left: 4px solid var(--green);
  border-radius: 0 12px 12px 0;
  background: color-mix(in srgb, var(--green) 8%, var(--surface));
  padding: 18px 20px;
}

.takeaway h2 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.takeaway p {
  margin: 0;
}

.sources {
  border-top: 1px solid var(--border-soft);
}

.sources ol {
  padding-left: 1.2rem;
}

.sources li {
  padding-left: 4px;
}

.source-note {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: .76rem;
}

.related-posts {
  border-top: 1px solid var(--border-soft);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.related-card {
  display: block;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  padding: 15px;
  font-size: .88rem;
  font-weight: 760;
  line-height: 1.35;
  text-decoration: none;
}

.related-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.site-footer {
  border-top: 1px solid var(--border-soft);
  background: var(--footer);
}

.footer-inner {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto;
  padding: 30px 0 35px;
  color: var(--muted-2);
  font-size: .78rem;
}

.footer-meta {
  display: flex;
  justify-content: space-between;
  gap: 26px;
}

.footer-meta p {
  max-width: 730px;
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 14px;
  white-space: nowrap;
}

.community-signoff {
  margin: 22px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 720;
  text-align: center;
}

.community-heart {
  color: var(--red);
}

.blog-wrap {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto;
  padding: 60px 0 90px;
}

.blog-hero {
  max-width: 850px;
}

.blog-hero h1 {
  font-size: clamp(2.6rem, 7vw, 5.1rem);
}

.blog-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  margin-top: 38px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 15px;
}

.blog-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.blog-results {
  margin: 13px 0 0;
  color: var(--muted-2);
  font-size: .78rem;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  margin-top: 26px;
}

.post-card {
  display: flex;
  min-height: 270px;
  flex-direction: column;
  border: 1px solid var(--border-soft);
  border-radius: 17px;
  background: var(--surface);
  padding: 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .08);
}

.post-card[hidden] {
  display: none;
}

.post-card:hover {
  border-color: color-mix(in srgb, var(--brand) 60%, var(--border));
  transform: translateY(-3px);
}

.post-card .card-category {
  margin: 0 0 11px;
  color: var(--brand);
  font-size: .67rem;
  font-weight: 850;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.post-card h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -.025em;
}

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

.post-card p {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: .86rem;
}

.post-card .card-meta {
  margin-top: auto;
  color: var(--muted-2);
  font-size: .72rem;
}

.research-note {
  margin-top: 54px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--surface-2);
  padding: 21px;
}

.research-note h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.research-note p {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  max-width: calc(100% - 36px);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text);
  padding: 10px 13px;
  font-size: .8rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .article-shell {
    display: block;
  }

  .toc {
    position: static;
    margin-bottom: 35px;
  }

  .toc ol {
    columns: 2;
    column-gap: 25px;
  }

  .post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .brand span {
    display: none;
  }

  .header-nav a:not(:first-child) {
    display: none;
  }

  .theme-select {
    max-width: 104px;
  }

  .article-shell {
    padding-top: 32px;
  }

  .article-header h1 {
    font-size: clamp(2.1rem, 12vw, 3.25rem);
  }

  .toc ol {
    columns: 1;
  }

  .tool-grid,
  .blog-controls,
  .related-grid {
    grid-template-columns: 1fr;
  }

  .mobile-presets {
    grid-template-columns: repeat(2, 1fr);
  }

  .post-grid {
    grid-template-columns: 1fr;
  }

  .post-card {
    min-height: 0;
  }

  .footer-meta {
    display: block;
  }

  .footer-links {
    margin-top: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
