  :root {
    --paper: #FBFAF7;
    --ink: #1D2229;
    --muted: #5C6370;
    --accent: #4A4E55;
    --accent-bright: #8A8F98;
    --line: #E6E2D8;
    --thumb-bg: #EFEDE6;
    --seal: #C43C2C;
    --serif: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", "Times New Roman", serif;
    --sans: "Avenir Next", Avenir, "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --paper: #14171C; --ink: #E9E6DE; --muted: #9AA0AB; --accent: #B9BEC6;
      --accent-bright: #808893; --line: #2A2F37; --thumb-bg: #1E232B; --seal: #D8553F;
    }
  }
  :root[data-theme="dark"] {
    --paper: #14171C; --ink: #E9E6DE; --muted: #9AA0AB; --accent: #B9BEC6;
    --accent-bright: #808893; --line: #2A2F37; --thumb-bg: #1E232B; --seal: #D8553F;
  }
  :root[data-theme="light"] {
    --paper: #FBFAF7; --ink: #1D2229; --muted: #5C6370; --accent: #4A4E55;
    --accent-bright: #8A8F98; --line: #E6E2D8; --thumb-bg: #EFEDE6; --seal: #C43C2C;
  }

  html { background: var(--paper); }
  body {
    background: var(--paper); color: var(--ink);
    font-family: var(--sans); font-size: 15px; line-height: 1.62; margin: 0;
  }
  .page { max-width: 880px; margin: 0 auto; padding: 48px 28px 64px; }
  a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
  a:hover { border-bottom-color: var(--accent); }
  a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

  .eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-weight: 600; }

  .mast-top { display: flex; justify-content: space-between; align-items: baseline; }
  a.lang {
    font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
    font-weight: 600; color: var(--muted); border-bottom: none;
  }
  a.lang:hover { color: var(--accent); border-bottom: none; }

  header.masthead { margin-bottom: 0; }
  header.masthead h1 {
    font-family: var(--serif); font-size: 46px; font-weight: 600;
    letter-spacing: -.01em; line-height: 1.05; margin: 10px 0 8px; text-wrap: balance;
  }
  .role { font-size: 17px; color: var(--ink); margin: 0 0 6px; }
  .role b { font-weight: 600; }
  .contacts { color: var(--muted); font-size: 14px; margin: 0; }
  .contacts a { color: var(--muted); border-bottom-color: var(--line); }
  .contacts a:hover { color: var(--accent); }

  canvas.sec-orn { display: block; width: 112px; height: 20px; margin: 10px 0 2px; cursor: pointer; }

  .toc-slot { margin: 14px 0 40px; }
  nav.toc {
    display: flex; flex-wrap: wrap; gap: 4px 18px;
    margin: 0; padding: 12px 0;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px;
    transition: padding .26s cubic-bezier(.22,.61,.36,1),
                font-size .26s cubic-bezier(.22,.61,.36,1),
                gap .26s cubic-bezier(.22,.61,.36,1),
                border-top-color .26s ease;
  }
  nav.toc a { color: var(--ink); border-bottom: none; }
  nav.toc a:hover { color: var(--accent); }
  nav.toc.is-stuck {
    position: fixed; z-index: 20; top: 0;
    left: var(--toc-left); width: var(--toc-width); box-sizing: border-box;
    flex-wrap: nowrap; gap: 4px 14px; overflow-x: auto;
    padding: 8px 0 7px; font-size: 11px;
    background:
      linear-gradient(color-mix(in srgb, var(--accent) 38%, transparent), color-mix(in srgb, var(--accent) 38%, transparent)) 0 100% / var(--toc-progress, 0%) 1px no-repeat,
      color-mix(in srgb, var(--paper) 98%, transparent);
    border-top-color: transparent;
    scrollbar-width: none;
    animation: toc-settle .26s cubic-bezier(.22,.61,.36,1);
  }
  @keyframes toc-settle {
    from { opacity: .58; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
  }
  nav.toc.is-stuck::-webkit-scrollbar { display: none; }
  nav.toc.is-stuck a {
    flex: 0 0 auto; color: var(--muted);
    transition: color .24s ease;
  }
  nav.toc.is-stuck a.is-current,
  nav.toc.is-stuck a[aria-current="location"] { color: var(--ink); }
  nav.toc.is-stuck a:hover { color: var(--ink); }
  @media (prefers-reduced-motion: reduce) {
    nav.toc, nav.toc.is-stuck a { transition: none; }
    nav.toc.is-stuck { animation: none; }
  }

  section { margin-top: 52px; }
  section > h2 {
    font-family: var(--serif); font-size: 29px; font-weight: 600;
    letter-spacing: -.005em; margin: 6px 0 20px; text-wrap: balance;
  }
  .sec-label { display: block; margin-bottom: 0; }
  section > h2 + p { margin-top: 0; }
  p.lead { font-size: 16.5px; max-width: 66ch; }
  section p { max-width: 72ch; }

  h3 { font-family: var(--serif); font-size: 19.5px; font-weight: 600; margin: 26px 0 4px; }
  .meta {
    font-size: 12.5px; color: var(--muted); letter-spacing: .04em;
    text-transform: uppercase; margin: 0 0 8px;
  }
  .meta b { color: var(--accent); font-weight: 600; }

  ul { padding-left: 20px; margin: 8px 0; }
  li { margin: 5px 0; max-width: 70ch; }
  li::marker { color: var(--accent-bright); }

  dl.skills { margin: 0; display: grid; grid-template-columns: 168px 1fr; row-gap: 12px; column-gap: 20px; }
  dl.skills dt { font-weight: 600; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; padding-top: 2px; }
  dl.skills dd { margin: 0; color: var(--ink); }
  dl.skills dd span.plus { color: var(--muted); }

  .xp { border-top: 1px solid var(--line); padding-top: 4px; }
  .xp:first-of-type { border-top: none; padding-top: 0; }
  .xp h3 { margin-top: 20px; }

  .tablewrap { overflow-x: auto; }
  table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 12px 0 4px; }
  th, td { text-align: left; padding: 7px 14px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
  th { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
  td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

  .card {
    display: grid; grid-template-columns: 208px 1fr;
    gap: 8px 26px; padding: 26px 0; border-top: 1px solid var(--line);
  }
  .card:first-of-type { border-top: none; padding-top: 8px; }
  .card figure { margin: 4px 0 0; grid-row: span 3; }
  .card figure canvas.sigil {
    width: 100%; aspect-ratio: 4 / 3; display: block;
    background: transparent; cursor: pointer;
  }
  .card figure figcaption {
    font: 10px/1.5 var(--mono); color: var(--muted); letter-spacing: .05em; margin-top: 6px;
  }
  .card h3 { margin: 0; }
  .card .meta { margin-bottom: 2px; }
  .card .body { grid-column: 2; }
  .card .body p { margin: 6px 0; }
  .press { font-size: 13px; color: var(--muted); margin-top: 8px; }
  .press a { white-space: nowrap; }

  .op { display: grid; grid-template-columns: 236px 1fr; gap: 8px 26px; padding: 18px 0; border-top: 1px solid var(--line); }
  .op:first-of-type { border-top: none; padding-top: 6px; }
  .op-def { font-family: var(--serif); font-size: 17px; line-height: 1.45; margin: 0; text-wrap: balance; }
  ul.op-list { list-style: none; padding: 0; margin: 2px 0 0; }
  ul.op-list li { margin: 0 0 7px; max-width: none; }
  ul.op-list a { font-size: 12.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; border-bottom: none; }
  ul.op-list a:hover { border-bottom: 1px solid var(--accent); }
  h3[id] { scroll-margin-top: 14px; }

  .row { padding: 13px 0; border-top: 1px solid var(--line); max-width: none; }
  .row:first-of-type { border-top: none; }
  .row h3 { display: inline; font-size: 16.5px; margin: 0; }
  .row .when { color: var(--muted); font-size: 12.5px; margin-left: 8px; }
  .row p { margin: 3px 0 0; color: var(--ink); font-size: 14px; }

  ol.pubs { padding-left: 20px; }
  ol.pubs li { margin: 10px 0; }

  footer.colophon {
    margin-top: 60px; padding-top: 18px; border-top: 1px solid var(--line);
    color: var(--muted); font-size: 13px;
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px;
  }
  footer.colophon .col-note { font: 10.5px/1.5 var(--mono); letter-spacing: .05em; width: 100%; text-align: center; }

  /* ---------- regole di frammentazione (in CSS base: dentro @media print
     Chromium le ignora sulle card grid con figure in grid-row span) ---------- */
  .card, .xp, .row, .op, table tr { break-inside: avoid; }
  section > h2, h3, .sec-label { break-after: avoid; }
  p, li { orphans: 3; widows: 3; }

  /* ---------- print button ---------- */
  .printbtn {
    position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    background: var(--ink); color: var(--paper);
    border: none; border-radius: 999px;
    font: 600 13px/1 var(--sans);
    padding: 11px 16px; cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,.18);
  }
  .printbtn:hover { background: var(--accent); }
  .printbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  @media (max-width: 640px) {
    header.masthead h1 { font-size: 34px; }
    .card { grid-template-columns: 1fr; }
    .card figure { grid-row: auto; max-width: 340px; }
    .card .body { grid-column: auto; }
    .op { grid-template-columns: 1fr; }
    dl.skills { grid-template-columns: 1fr; row-gap: 2px; }
    dl.skills dd { margin-bottom: 10px; }
  }

  @page { size: A4; margin: 16mm 15mm; }
  @media print {
    :root, :root[data-theme="dark"] {
      --paper: #FFFFFF; --ink: #1D2229; --muted: #5C6370; --accent: #4A4E55;
      --accent-bright: #8A8F98; --line: #DDD9CF; --thumb-bg: #F2F0EA; --seal: #C43C2C;
    }
    html, body { background: #FFFFFF; }
    body { font-size: 10.2pt; line-height: 1.5; }
    .page { max-width: none; padding: 0; }
    .toc-slot, .printbtn, a.lang { display: none; }
    header.masthead h1 { font-size: 30pt; }
    section { margin-top: 26px; }
    section > h2 { font-size: 19pt; }
    #archivio, #archive { break-before: page; }
    #pubblicazioni, #publications { break-before: page; }
    .card { grid-template-columns: 168px 1fr; padding: 16px 0; }
    a { color: inherit; border-bottom: none; }
    a[href^="http"] { color: var(--accent); }
  }
