:root {
  color-scheme: light;
  --sans: "Libre Franklin", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --serif: "Source Serif 4", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --display: "Playfair Display", "Source Serif 4", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --ink: #121212;
  --paper: #ffffff;
  --rule: rgba(17, 17, 17, 0.15);
  --link: #1c3f7a;
  --link-hover: #0f2c5f;
  --link-visited: #4a4073;
}
html { font-family: var(--sans); font-size: 16px; }
@media (min-width: 960px) { html { font-size: 17px; } }
body {
  margin: 0;
  line-height: 1.65;
  color: var(--ink);
  font-family: var(--serif);
  background: var(--paper);
  padding: 0;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.download-grid figure {
  margin: 0;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: #fafafa;
  box-shadow: 0 8px 24px rgba(17, 17, 17, 0.05);
}

.download-grid img {
  width: 100%;
  height: auto;
  border-radius: 0.5rem;
  border: 1px solid rgba(17, 17, 17, 0.05);
}

.download-grid figcaption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Headings and chrome use sans for contrast */
header, nav, footer { font-family: var(--sans); letter-spacing: 0.01em; }
h1, h2, h3 { font-family: var(--display); letter-spacing: 0.01em; }

body > header,
body > main,
body > footer,
body > section,
body > aside {
  max-width: 132ch;
  margin: 0 auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
  padding-block: 1.5rem;
}
body > header { padding-block: 1rem 0.5rem; }
body > footer { padding-block: 1rem 2rem; }

.page-shell {
  background: var(--paper);
  max-width: 1500px;
  margin: 0 auto;
  overflow: hidden;
  border-inline: 0;
}
.page-shell > section,
.page-shell > main,
.page-shell > footer {
  max-width: 132ch;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
  padding-block: 1.5rem;
}
.page-shell > section { padding-block: 1rem 1.25rem; }
.page-shell > footer { padding-block: 1.25rem 2rem; }

header.site-hero {
  padding: 0 0 1.5rem;
  margin-bottom: 0;
}
/* Avoid double padding for articles nested in main */
main > article { padding-inline: 0; }
/* Avoid double inset on headers inside articles */
article > header,
article > footer { padding-inline: 0; }

/* Typography rhythm */
p, ul, ol, dl, figure, pre, blockquote, table { margin-block: 1rem; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 2.5vw + 0.5rem, 2.2rem); }
h2 { font-size: clamp(1.25rem, 1.4vw + 0.4rem, 1.5rem); }
h3 { font-size: clamp(1.05rem, 1vw + 0.35rem, 1.2rem); }

/* Media */
img, picture, video { max-width: 100%; height: auto; }

/* Simple media row for side-by-side figures */
.figure-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  align-items: start;
}
.figure-row figure { margin: 0; }
.figure-row img { display: block; width: 100%; height: auto; border-radius: 8px; }
.figure-row figcaption { font-size: 0.9em; color: #374151; margin-top: 0.35rem; }

/* Modal image dialog (HTML5 <dialog>) */
.zoomable { cursor: zoom-in; display: inline-block; background: transparent; border: 0; padding: 0; }
dialog.image-modal { border: none; padding: 0; max-width: 96vw; max-height: 96vh; }
dialog.image-modal::backdrop { background: rgba(0,0,0,0.85); }
.image-modal__content { position: relative; }
.image-modal__img { display: block; max-width: 96vw; max-height: 96vh; width: auto; height: auto; border-radius: 10px; }
.dialog-close { position: absolute; top: 8px; right: 10px; background: rgba(0,0,0,0.55); color: #fff; border: 1px solid rgba(255,255,255,0.25); border-radius: 6px; padding: 0.25rem 0.5rem; font-family: var(--sans); }
.dialog-close:hover { background: rgba(0,0,0,0.7); }

/* Code */
pre { overflow: auto; padding: 0.75rem; background: #eef0f3; border: 1px solid #d9dde3; border-radius: 6px; font-size: 0.95rem; }
code, pre, kbd, samp { font-family: var(--mono); }
code { font-size: 0.95em; }
/* Inline code should blend with text; no box */
code { background: transparent; border: 0; padding: 0.05em 0.15em; border-radius: 0; }
pre code { background: none; padding: 0; }

/* Blockquotes */
blockquote { padding: 0.5rem 1rem; border-inline-start: 4px solid currentColor; background: rgba(127,127,127,0.06); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5rem; border-bottom: 1px solid rgba(127,127,127,0.2); text-align: left; }

/* Rules + links */
hr { border: none; height: 1px; background: currentColor; opacity: 0.15; margin: 2rem 0; }
a { color: var(--link); text-decoration: underline; text-underline-offset: 0.15em; }
a:visited { color: var(--link-visited); }
a:hover { color: var(--link-hover); text-decoration-thickness: 0.12em; }
a:active { color: color-mix(in oklch, var(--link-hover) 80%, black); }

/* Focus visibility */
:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* Newspaper masthead */
.nyt-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.72rem;
}
.nyt-topbar__left,
.nyt-topbar__right {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}
.nyt-date,
.nyt-paper {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.nyt-separator {
  opacity: 0.5;
}
.nyt-topbar__right a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  font-weight: 600;
}
.weather-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #222;
  cursor: help;
  padding: 0;
}
.weather-chip:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.weather-temp {
  font: inherit;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px dashed currentColor;
  padding-bottom: 0.05rem;
}
.weather-tooltip {
  position: absolute;
  top: 130%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 420px;
  padding: 1.1rem 1.2rem 1.2rem;
  border: 1px solid rgba(17, 17, 17, 0.18);
  border-radius: 0.75rem;
  background: #fff;
  color: #222;
  font-size: 0.85rem;
  line-height: 1.35;
  box-shadow: 0 18px 40px rgba(17, 17, 17, 0.12);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 10;
  white-space: normal;
}
.weather-tooltip__header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-family: var(--sans);
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}
.weather-tooltip__temp {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.weather-tooltip__condition {
  font-size: 1rem;
  color: #333;
}
.weather-tooltip__wind {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #555;
  margin-left: auto;
}
.weather-tooltip__meta {
  display: block;
  color: #555;
  font-size: 0.8rem;
  text-align: center;
  margin-top: 0.35rem;
}
.weather-tooltip__tides {
  display: block;
  margin-top: 0.25rem;
  text-align: center;
  font-size: 0.78rem;
  color: #555;
}
.weather-tooltip__label {
  display: block;
  margin-top: 0.85rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #666;
  text-align: center;
}
.weather-tooltip__list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(110px, 1fr);
  gap: 0.65rem;
}
.weather-tooltip__list li {
  margin: 0;
  border: 1px solid rgba(17, 17, 17, 0.16);
  border-radius: 0.7rem;
  padding: 0.6rem 0.55rem;
  background: #fbfbfb;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 0.25rem;
  text-align: center;
}
.weather-card__label {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #555;
  min-height: 1.8em;
}
.weather-card__temp {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: #222;
  display: grid;
  gap: 0.2rem;
}
.weather-card__condition {
  font-size: 0.75rem;
  color: #555;
  min-height: 2.4em;
}
.weather-chip:hover .weather-tooltip,
.weather-chip:focus-visible .weather-tooltip {
  opacity: 1;
  visibility: visible;
}
.nyt-logo {
  text-align: center;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 1rem;
  border-bottom: 1px solid var(--rule);
}
.nyt-logo h1,
.nyt-logo h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0.02em;
}
.nyt-logo a {
  color: inherit;
  text-decoration: none;
}
.post-nav--minimal {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}
.nyt-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 2px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.nyt-nav a {
  text-decoration: none;
  color: inherit;
}
.newspaper-column {
  margin-top: 1.5rem;
}

/* Post-specific demo tuning: keep calculators intact */

/* Calculator demos: keep internal type at 16px for layout fidelity */
article section[aria-label^="Calculator mockup"] { font-size: 16px; line-height: 1.4; }
.about-details {
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  background: #f8fafc;
}
.about-details summary {
  cursor: pointer;
  font-weight: 600;
  font-family: var(--sans);
  color: #111;
}
.about-details summary::-webkit-details-marker { display: none; }
.about-details p:last-of-type { margin-bottom: 0.25rem; }

/* Blog index layout */
.recent-posts {
  display: grid;
  gap: 0.6rem;
}
.recent-posts > header {
  margin: 0;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--rule);
  text-align: right;
}
.recent-posts > header h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}
.demos-block > header,
.archive-section > header {
  text-align: right;
}
.lead-story {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2rem;
}
.lead-story h3 {
  font-size: clamp(1.6rem, 2.2vw, 2.1rem);
  line-height: 1.2;
  margin-top: 0.2rem;
}
.recent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem;
}
.recent-post {
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
}
.recent-post:nth-child(-n+3) {
  border-top: none;
  padding-top: 0;
}
.recent-post:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}
.recent-post h3 {
  margin-bottom: 0.35rem;
}
.post-meta {
  color: #4b4b4b;
  margin-top: 0.35rem;
}
.post-excerpt p {
  margin-top: 1rem;
}
.post-pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-family: var(--sans);
}
.post-pagination .load-more {
  border: 1px solid var(--rule);
  background: transparent;
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.post-pagination .load-more:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.post-pagination .load-more:hover {
  background: #f6f3ee;
}
.post-pagination--post {
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
  justify-content: space-between;
  flex-wrap: wrap;
}
.post-pagination--post a {
  font-weight: 600;
}
.demos-block {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--rule);
}
.demos-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem 1.5rem;
}
.demos-list li {
  display: grid;
  gap: 0.25rem;
}
.demos-list time {
  font-size: 0.85rem;
  color: #4b4b4b;
}
.archive-section {
  margin: 3rem 0 0;
  padding-top: 1.5rem;
  border-top: 2px solid var(--rule);
}
.archive-grid {
  margin-top: 1.5rem;
}
.archive-year h3 {
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
  font-family: var(--sans);
}
.archive-year {
  margin-bottom: 1.5rem;
}
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
  column-count: 4;
  column-gap: 1.5rem;
}
.archive-list li {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
  break-inside: avoid;
}
.archive-month-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: #333;
}
.archive-list time {
  font-size: 0.9rem;
  color: #4b4b4b;
}
@media (max-width: 900px) {
  .nyt-topbar {
    flex-direction: column;
    gap: 0.5rem;
  }
  .recent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .archive-list {
    column-count: 3;
  }
}
@media (max-width: 640px) {
  .recent-grid {
    grid-template-columns: 1fr;
  }
  .archive-list {
    column-count: 2;
  }
  .nyt-nav {
    justify-content: flex-start;
  }
}
@media (max-width: 480px) {
  .archive-list {
    column-count: 1;
  }
}
.demo-strip ul {
  display: grid;
  gap: 0.35rem;
  list-style: none;
  padding: 0;
}

.post-shell,
.demo-shell {
  max-width: 92ch;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 3rem) clamp(1.5rem, 5vw, 2.5rem) 3rem;
}
.demo-hero {
  margin-bottom: 2rem;
}
.demo-hero p {
  max-width: 60ch;
}
.post-nav,
.demo-nav {
  display: flex;
  gap: 1rem;
  font-family: var(--sans);
  margin-bottom: 1.5rem;
}
.demo-kicker {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.8rem;
  color: #6b5c4d;
}
.demo-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 1.5rem;
}
