:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #fffefa;
  --text: #191815;
  --body-text: #23211d;
  --muted: #615e56;
  --soft: #837d70;
  --line: #d9d2c4;
  --line-soft: #ebe6dc;
  --accent: #0b6f68;
  --accent-strong: #8f1d2c;
  --code-bg: #ede8de;
  --shadow: 0 24px 70px rgba(45, 38, 24, 0.08);
  --content: 1080px;
  --measure: 780px;
  --article: var(--content);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10110f;
  --surface: #171814;
  --text: #ece7db;
  --body-text: #ddd7ca;
  --muted: #b4ada1;
  --soft: #918a80;
  --line: #37332c;
  --line-soft: #26231f;
  --accent: #7ddbd1;
  --accent-strong: #f0a6ad;
  --code-bg: #22241f;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.7;
}

body {
  margin: 0;
  min-height: 100vh;
  font-weight: 400;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent-strong);
}

.site-header,
.site-footer,
main {
  width: min(var(--content), calc(100vw - 40px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 24px;
  padding: 14px 0 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.site-nav a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
}

.site-nav .home-link {
  min-width: 38px;
  padding-inline: 11px;
}

.home-link svg {
  display: block;
  width: 1.12rem;
  height: 1.12rem;
  fill: none;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.site-nav a:hover {
  background: var(--line-soft);
  color: var(--text);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  position: relative;
  inline-size: 48px;
  block-size: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.theme-toggle:hover {
  background: var(--line-soft);
  color: var(--text);
}

.theme-toggle span {
  grid-area: 1 / 1;
  font-size: 1.2rem;
  line-height: 1;
  transition: opacity 140ms ease, transform 140ms ease;
}

.theme-toggle-moon,
:root[data-theme="dark"] .theme-toggle-sun {
  opacity: 0;
  transform: scale(0.7) rotate(-20deg);
}

:root[data-theme="dark"] .theme-toggle-moon {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.intro {
  max-width: var(--measure);
  padding: 18px 0 48px;
}

.intro.compact {
  padding: 56px 0 26px;
}

.intro h1,
.post-header h1 {
  margin: 0;
  color: var(--text);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: clamp(2.5rem, 6vw, 4.6rem);
  font-weight: 680;
  line-height: 0.94;
  letter-spacing: 0;
}

.intro p {
  max-width: 38rem;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.16rem;
}

.post-index,
.tag-list,
.post {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.home-layout {
  padding-bottom: 8px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-heading span,
time,
.post-meta,
.site-footer,
.tag-list span {
  color: var(--muted);
}

.post-list,
.tag-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-row {
  padding: 0;
  border-bottom: 1px solid var(--line-soft);
}

.post-row:last-child {
  border-bottom: 0;
}

.post-row > a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: baseline;
  padding: 22px 24px 6px;
  color: var(--text);
  text-decoration: none;
}

.post-row > a:hover .post-title {
  color: var(--accent);
}

.post-title {
  font-size: 1.12rem;
  font-weight: 620;
  line-height: 1.35;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 22px;
}

.tags a {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 620;
  text-decoration: none;
}

.tags a:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  color: var(--accent);
}

.post {
  max-width: var(--article);
  padding: 28px clamp(24px, 5vw, 64px) 44px;
  margin-top: 22px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  margin-bottom: 22px;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.back-link:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  color: var(--accent);
}

.post-header h1 {
  max-width: none;
  font-size: clamp(2.35rem, 4.2vw, 3.45rem);
  line-height: 1.02;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.inline-tags {
  display: inline-flex;
  margin-top: -2px;
  padding: 0;
}

.post-meta .inline-tags {
  padding: 0;
}

.post-body {
  margin-top: 22px;
  color: var(--body-text);
  font-size: 1rem;
  font-weight: 400;
}

.post-body h1,
.post-body h2,
.post-body h3 {
  max-width: none;
  color: var(--text);
  font-weight: 680;
  line-height: 1.18;
  margin: 1.25em 0 0.45em;
  letter-spacing: 0;
}

.post-body > h1:first-child,
.post-body > h2:first-child,
.post-body > h3:first-child {
  margin-top: 0.85em;
}

.post-body h1 {
  font-size: clamp(1.95rem, 3vw, 2.45rem);
}

.post-body h2 {
  font-size: clamp(1.55rem, 2.4vw, 1.95rem);
}

.post-body h3 {
  font-size: clamp(1.25rem, 2vw, 1.45rem);
}

.post-body p,
.post-body ul,
.post-body ol {
  max-width: none;
  margin: 0.9em 0 1.05em;
  line-height: 1.74;
  font-weight: 400 !important;
}

.post-body li + li {
  margin-top: 0.35em;
}

.post-body blockquote {
  max-width: none;
  margin: 1.6em 0;
  padding: 0.1em 0 0.1em 1.1em;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.post-body pre {
  overflow-x: auto;
  white-space: pre;
  margin: 1.55em 0 1.8em;
  padding: 20px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  line-height: 1.62;
  font-weight: 400;
}

.post-body pre code,
.post-body pre .giallo-l,
.post-body pre span {
  display: inline-block;
  min-width: max-content;
  white-space: pre;
}

.post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  font-weight: 400 !important;
}

.post-body :not(pre) > code {
  padding: 0.1em 0.28em;
  background: var(--code-bg);
  border-radius: 5px;
}

.post-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0 1.2rem;
}

.footnote-definition {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: baseline;
  margin: 0.6rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.footnote-definition-label {
  color: var(--soft);
  font-size: 0.85rem;
  line-height: 1.7;
}

.footnote-definition p {
  margin: 0;
}

.footnote-definition:target {
  padding: 0.55rem 0.7rem;
  margin-inline: -0.7rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.footnote-definition:target .footnote-definition-label {
  color: var(--accent);
  font-weight: 800;
}

.footnote-reference:target,
.footnote-reference:has(a:target) {
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.tag-list {
  display: grid;
  gap: 0;
  padding: 8px 24px;
}

.tag-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line-soft);
}

.tag-list li:last-child {
  border-bottom: 0;
}

.tag-list a {
  font-weight: 720;
  text-decoration: none;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 34px 0 44px;
  margin-top: 42px;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

@media (min-width: 1120px) {
  :root {
    --content: 1240px;
  }

  .intro {
    max-width: 780px;
    padding-top: 10px;
  }
}

@media (min-width: 760px) and (max-width: 1119px) {
  .site-header,
  .site-footer,
  main {
    width: min(var(--content), calc(100vw - 56px));
  }

  .intro {
    padding-top: 18px;
  }

  .intro h1 {
    max-width: 10ch;
    font-size: clamp(3rem, 7vw, 4.4rem);
  }

  .post-row > a {
    padding-top: 24px;
  }
}

@media (max-width: 620px) {
  html {
    background: var(--bg);
  }

  .site-header,
  .site-footer,
  main {
    width: min(100% - 24px, var(--content));
  }

  .site-header,
  .header-controls,
  .post-row > a,
  .site-footer {
    display: block;
  }

  .site-nav,
  .theme-toggle,
  .site-footer span + span {
    margin-top: 12px;
  }

  .site-nav {
    width: 100%;
    justify-content: space-between;
    border-radius: 14px;
  }

  .site-nav a {
    flex: 1;
    text-align: center;
  }

  .intro h1,
  .post-header h1 {
    font-size: clamp(2.2rem, 11vw, 3.3rem);
  }

  .intro p {
    font-size: 1rem;
  }

  .post-index,
  .tag-list,
  .post {
    border-radius: 14px;
  }

  .section-heading,
  .post-row > a,
  .tags {
    padding-left: 16px;
    padding-right: 16px;
  }

  .post-row > a {
    padding-bottom: 4px;
  }

  .post-row > a time {
    display: block;
    margin-top: 6px;
  }

  .intro {
    padding: 16px 0 28px;
  }

  .post {
    padding: 24px 18px 34px;
    margin-top: 20px;
  }

  .post-body {
    margin-top: 36px;
    font-size: 1.02rem;
  }

  .post-body pre {
    margin-left: -8px;
    margin-right: -8px;
    border-radius: 8px;
  }
}
