:root {
  --bg: #ffffff;
  --fg: #222222;
  --muted: #777777;
  --line: #e7e7e7;
  --accent: #5b3fd6;
  --max: 37em;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151515;
    --fg: #dcdcdc;
    --muted: #8c8c8c;
    --line: #2c2c2c;
    --accent: #a995ff;
  }
}

/* Tema bianco e nero (si attiva con lo switch nell'header) */
html[data-theme="mono"] {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #555555;
  --line: #d6d6d6;
  --accent: #000000;
  color-scheme: light;
}
html[data-theme="mono"] a { text-decoration-color: currentColor; }
html[data-theme="mono"] .content a { color: #000; text-decoration: underline; }
html[data-theme="mono"] .latest em { color: #000; text-decoration: underline; }
html[data-theme="mono"] hr { border-top-color: #000; }
html[data-theme="mono"] .content blockquote { border-left-color: #000; color: #333; }
html[data-theme="mono"] ul.writing a:hover,
html[data-theme="mono"] .topics a:hover { text-decoration-color: #000; }

/* Switch tema */
.theme-toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.theme-toggle svg { width: 1.05rem; height: 1.05rem; }
.theme-toggle:hover, .theme-toggle:focus-visible { color: var(--fg); }
.theme-toggle:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 4px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: calc(15px + 0.25vw);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 2rem 1.25rem 4rem; }

a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: currentColor; }

/* header */
header.site { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 3rem; }
header.site a { text-decoration: none; }
header.site .brand { font-weight: 600; }
header.site .sep { color: var(--muted); margin: 0 0.15em; }
header.site .links { display: flex; gap: 1rem; color: var(--muted); }
header.site .links a:hover { color: var(--fg); }

/* headings */
h1, h2, h3, h4 { line-height: 1.3; margin: 1em 0 0.5em; font-weight: 500; letter-spacing: -0.015em; }
h1 { font-size: calc(1.35em + 0.55vw); line-height: 1.25; margin-top: 0; margin-bottom: 0.25em; letter-spacing: -0.02em; }
h2 { font-size: calc(1em + 0.2vw); }
h3 { font-size: 1em; }
h2 a { text-decoration: none; }
h2.label, .more h2, .subscribe h2 { color: var(--muted); font-weight: 500; }
.quiet { color: var(--muted); text-decoration: none; }

hr { border: 0; border-top: 1px solid var(--line); margin: 2.25rem 0; }

/* home */
.latest { display: block; text-decoration: none; }
.latest strong { display: block; font-size: calc(1em + 0.2vw); font-weight: 500; }
.latest .meta, .meta { color: var(--muted); font-size: 0.875em; display: block; margin: 0.15em 0 0.4em; }
.latest .desc { display: block; color: var(--fg); }
.latest em { font-style: normal; color: var(--accent); white-space: nowrap; }
.latest:hover strong { text-decoration: underline; text-decoration-color: var(--line); }

.topics a { text-decoration: none; color: var(--muted); }
.topics a:hover { color: var(--fg); text-decoration: underline; }

ul.writing { list-style: none; padding: 0; margin: 0; }
ul.writing li { margin: 0.2rem 0; }
ul.writing a { text-decoration: none; display: block; }
ul.writing a:hover { text-decoration: underline; text-decoration-color: var(--line); }
ul.writing .date { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 0.6em; white-space: nowrap; }

/* post */
article.post .meta { margin: -0.25rem 0 2rem; }
.content > :first-child { margin-top: 0; }
.content p, .content ul, .content ol, .content blockquote, .content pre, .content figure, .content table { margin: 0 0 1em; }
.content ul, .content ol { padding-left: 1.4rem; }
.content li { margin: 0.25rem 0; }
.content a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.content a:hover { text-decoration-color: currentColor; }
.content blockquote { border-left: 2px solid var(--line); padding-left: 1rem; color: var(--muted); margin-left: 0; }
.content img, .content video { max-width: 100%; height: auto; border-radius: 6px; display: block; }
.content hr { margin: 2rem 0; }
.content code { font-family: var(--mono); font-size: 0.88em; background: color-mix(in srgb, var(--fg) 8%, transparent); padding: 0.12em 0.35em; border-radius: 4px; }
.content pre { overflow-x: auto; padding: 0.9rem 1rem; border-radius: 6px; background: color-mix(in srgb, var(--fg) 6%, transparent); line-height: 1.45; }
.content pre code { background: none; padding: 0; }
.content table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.content th, .content td { border-bottom: 1px solid var(--line); padding: 0.4rem 0.6rem; text-align: left; }

.post-topics { color: var(--muted); font-size: 0.875em; margin: 2rem 0 0; }
.post-topics a { text-decoration: none; }
.post-topics a:hover { text-decoration: underline; }

/* menzioni e correlati */
.more ul { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.more li { margin: 0.6rem 0; }
.more a { text-decoration: none; }
.more a:hover strong, .more ul.plain a:hover { text-decoration: underline; }
.more .desc { color: var(--muted); }
.more ul.plain li { margin: 0.25rem 0; }

/* iscrizione + footer */
.subscribe { margin-top: 2rem; }
.subscribe h2 { margin-top: 0; }
.subscribe p { margin: 0; }
footer.site { display: flex; gap: 1rem; margin-top: 3rem; color: var(--muted); font-size: 0.875em; }
footer.site a { text-decoration: none; }
footer.site a:hover { color: var(--fg); text-decoration: underline; }

@media (max-width: 480px) {
  header.site { margin-bottom: 2rem; }
}
