/* Tributar-IA — shared design system. Every page loads this file first.
 *
 * The idea (brand.md §9): the jurist who reads forty pages and underlines the three
 * lines that matter. White paper and ink, text first. The mark's blue, "notte", is
 * structure only: headings (light mode) and the footer; never a link, button, border or
 * state. Two marks carry the brand:
 *   - the red pencil, "timbro": thin lines (link underlines, margin notes, the hyphen in
 *     Tributar-IA, the loader) and the primary button;
 *   - the yellow highlighter marks what matters on the page: the references the search
 *     recognised, what the reader has selected (current page and tab, active filters,
 *     the article being read), and on presentation pages at most one phrase or figure
 *     per section. Never a background, never decoration.
 * Dark mode starts from the operating system's setting; a discreet toggle in the header
 * overrides it (theme.js sets data-theme on <html>).
 *
 * Sections: 1 fonts · 2 tokens (the palette) · 3 base · 4 layout · 5 header and footer ·
 * 6 buttons · 7 forms and tabs · 8 tags, citations, highlight, margin note · 9 notices,
 * loader, spinner, empty state · 10 content pages · 11 search tools · 12 utilities.
 * Page stylesheets: giurisprudenza.css (index), normativa.css, chat.css.
 */

/* 1 ── Fonts: self-hosted (fonts/, OFL), so visitors' browsers call no third party. */
@font-face { font-family: "Newsreader"; src: url("fonts/newsreader-latin-opsz-normal.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("fonts/newsreader-latin-opsz-italic.woff2") format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

/* 2 ── Tokens: THE PALETTE. To switch palette, change the values in these two blocks:
   light in :root, dark in :root[data-theme="dark"] (theme.js sets the attribute from the
   system setting or the header toggle). No other stylesheet names a colour —
   site.test.mjs fails if one does — and nothing else needs touching: images/favicon.svg
   is the brand mark, whose three colours belong to the mark and not to the palette. */
:root {
    color-scheme: light;

    --paper: #FFFFFF;          /* page ground */
    --paper-2: #F4F5F6;        /* recessed areas: footer, hover, code */
    --surface: #FFFFFF;        /* inputs, search card, reader */
    --ink: #16171A;
    --graphite: #5B5F66;       /* secondary text */
    --rule: #E1E3E6;           /* hairlines */
    --rule-strong: #C6CACF;    /* control borders */

    --timbro: #A8302A;         /* the brand accent ("timbro" in brand.md): text, thin lines */
    --timbro-fill: #A8302A;    /* the same accent as a filled button */
    --timbro-fill-strong: #8A2621;
    --on-timbro: #FFFFFF;      /* text on --timbro-fill */
    --verifica: #2E6B4F;       /* confirmations, "citazione verificata" */
    --verifica-soft: #E3EEE7;
    --attenzione: #C77A2B;     /* repealed law, warnings */
    --attenzione-text: #8A5214;
    --attenzione-soft: #F7EBDC;
    --hl: #F5E663;             /* the highlighter */
    --hl-ink: #16171A;         /* text on the highlighter, in both modes */
    --notte: #10203F;          /* the mark's blue: structure only (headings, footer) */
    --titolo: var(--notte);    /* headings; ink in dark mode */
    --on-notte: #E8ECF4;       /* text on --notte */
    --on-notte-2: #A9B4C8;     /* secondary text on --notte */
    --notte-rule: #3B4A6A;     /* link underlines on --notte */
    --timbro-on-notte: #EB7169;
    --struttura: #2E4A7D;      /* the mark's blue as a stroke: rules, timeline. --notte is a ground */

    --shadow: 0 1px 2px rgba(22, 23, 26, 0.05), 0 10px 30px rgba(22, 23, 26, 0.07);
    --backdrop: rgba(22, 23, 26, 0.32);

    --font-serif: "Newsreader", Georgia, serif;
    --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --radius: 4px;
    --radius-sm: 2px;
    --container: 1200px;
    --measure: 68ch;
    --header-h: 4rem;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --paper: #121315;
    --paper-2: #18191C;
    --surface: #1C1D21;
    --ink: #ECEDEE;
    --graphite: #A3A6AB;
    --rule: #2C2E33;
    --rule-strong: #45484E;

    --timbro: #EB7169;         /* lighter, so thin red lines read on dark paper */
    --timbro-fill: #C63F35;    /* a red button, not a coral one */
    --timbro-fill-strong: #D8534A;
    --on-timbro: #FFFFFF;
    --verifica: #74BC96;
    --verifica-soft: #1C2D24;
    --attenzione: #E0A159;
    --attenzione-text: #EAB06D;
    --attenzione-soft: #33271A;
    --titolo: var(--ink);
    --struttura: #7D95C4;      /* the same stroke, lightened to read on dark paper */

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
    --backdrop: rgba(0, 0, 0, 0.55);
}

/* 3 ── Base */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4 {
    margin: 0 0 0.5em;
    color: var(--titolo);
    font-family: var(--font-serif);
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

h1 { font-size: clamp(2rem, 1.35rem + 2.6vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 1.25rem + 1vw, 2rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }

p { margin: 0 0 1em; }

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

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

:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

img { max-width: 100%; height: auto; }

code, kbd, samp { font-family: var(--font-mono); font-size: 0.9em; }

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

[hidden] { display: none !important; }

/* 4 ── Layout */
.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding-inline: 1.5rem;
}

.container--narrow { max-width: 860px; }

.section { padding-block: 3.5rem; }
.section + .section { border-top: 1px solid var(--rule); }

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

@media (max-width: 860px) {
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
    .container { padding-inline: 1rem; }
    .section { padding-block: 2.5rem; }
}

/* 5 ── Header and footer: the same markup on every page, only aria-current changes. */
.site-header {
    position: sticky;
    z-index: 100;
    top: 0;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}

.site-header__inner {
    display: flex;
    min-height: var(--header-h);
    align-items: center;
    gap: 1.25rem;
}

/* The mark is the wordmark: the T inside the disc is the T of the name, so the name is
   never set as text here — it is lettering, in outlines, and cannot fall back to another
   face. Two files because that lettering is ink-dark and would vanish on dark paper;
   theme.js flips them, and without it the site stays light. */
.brand {
    display: inline-flex;
    flex: none;
    align-items: center;
    text-decoration: none;
}

.brand__logo { display: block; height: 2.25rem; width: auto; }
.brand__logo--scuro { display: none; }

:root[data-theme="dark"] .brand__logo { display: none; }
:root[data-theme="dark"] .brand__logo--scuro { display: block; }

.site-nav { margin-left: auto; }

.site-nav ul {
    display: flex;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav a {
    display: block;
    padding-block: 0.3rem;
    border-bottom: 2px solid transparent;
    color: var(--graphite);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.site-nav a:hover { color: var(--ink); }

/* Where you are is marked with the highlighter, drawn under the label. */
.site-nav a[aria-current="page"] {
    box-shadow: inset 0 -4px 0 var(--hl);
    color: var(--ink);
}

.auth-controls {
    display: inline-flex;
    min-height: 2rem;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.45rem;
}

.auth-account-link {
    color: var(--graphite);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
}

.auth-account-link:hover { color: var(--ink); text-decoration: underline; }
.auth-user-button { display: inline-flex; align-items: center; }
.auth-open-badge { color: var(--graphite); font-size: 0.75rem; white-space: nowrap; }

/* The theme switch: discreet, at the end of the header. It starts from the system's
   setting and overrides it only while the reader wants the other theme (theme.js). */
.theme-toggle {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--graphite);
    cursor: pointer;
}

.theme-toggle:hover { background: var(--paper-2); color: var(--ink); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; transition: transform 0.2s ease; }
.theme-toggle[aria-pressed="true"] svg { transform: rotate(180deg); }

/* Narrow screens: the header scrolls away with the page and the links become a row of
   their own, scrollable. One row needs about 1110px signed out (mark, five links,
   Accedi, Registrati, theme switch); measure again when a label or a button changes. */
@media (max-width: 1120px) {
    .site-header { position: static; }
    .site-header__inner { flex-wrap: wrap; gap: 0.25rem 1rem; padding-block: 0.75rem 0.25rem; }
    .site-nav { order: 2; width: 100%; margin-left: 0; overflow-x: auto; scrollbar-width: thin; }
    .auth-controls { order: 1; margin-left: auto; }
    .theme-toggle { order: 1; margin-left: 0; }
    .site-nav ul { gap: 1.25rem; }
}

/* The footer closes every page on the mark's blue, in both modes, with the mark in negative. */
.site-footer {
    background: var(--notte);
    color: var(--on-notte-2);
    font-size: 0.875rem;
}

.site-footer .brand__logo { display: none; }
.site-footer .brand__logo--scuro { display: block; }
.site-footer :focus-visible { outline-color: var(--on-notte); }

.site-footer__inner {
    display: grid;
    grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr));
    gap: 2rem;
    padding-block: 2.5rem;
}

.site-footer__brand p { max-width: 40ch; margin: 0.75rem 0 0; }

.site-footer__title {
    margin: 0 0 0.6rem;
    color: var(--on-notte);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-footer ul { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }

.site-footer a { color: var(--on-notte); text-decoration-color: var(--notte-rule); }
.site-footer a:hover { text-decoration-color: var(--timbro-on-notte); }

@media (max-width: 720px) {
    .site-footer__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .site-footer__brand { grid-column: 1 / -1; }
}

/* 6 ── Buttons */
.btn {
    display: inline-flex;
    min-height: 2.5rem;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn--primary { background: var(--timbro-fill); color: var(--on-timbro); }
.btn--primary:hover:not(:disabled) { background: var(--timbro-fill-strong); }

.btn--secondary { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn--secondary:hover:not(:disabled) { background: var(--ink); color: var(--paper); }

.btn--ghost {
    padding-inline: 0.5rem;
    background: transparent;
    color: var(--graphite);
    text-decoration: underline;
    text-decoration-color: var(--rule-strong);
    text-underline-offset: 0.2em;
}

.btn--ghost:hover:not(:disabled) { color: var(--ink); text-decoration-color: var(--timbro); }

.btn--sm { min-height: 2rem; padding: 0.3rem 0.75rem; font-size: 0.8125rem; }

.btn:disabled { cursor: not-allowed; opacity: 0.55; }

.icon-btn {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.icon-btn:hover:not(:disabled) { border-color: var(--ink); }
.icon-btn:disabled { cursor: not-allowed; opacity: 0.4; }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }

/* 7 ── Forms and tabs */
.input, .select, .textarea {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.4;
}

.input::placeholder, .textarea::placeholder { color: var(--graphite); opacity: 0.85; }

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--ink);
    outline: none;
    box-shadow: 0 0 0 1px var(--ink);
}

.field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--graphite);
    font-size: 0.8125rem;
    font-weight: 600;
}

.fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }

.fieldset > legend,
.label {
    margin-bottom: 0.5rem;
    padding: 0;
    color: var(--graphite);
    font-size: 0.8125rem;
    font-weight: 600;
}

.check {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.55rem;
    color: var(--ink);
    font-size: 0.875rem;
    cursor: pointer;
}

.check input,
.chip input,
.option input {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    margin: 0.2rem 0 0;
    accent-color: var(--ink);
}

.check small, .option small { display: block; color: var(--graphite); font-size: 0.8125rem; font-weight: 400; }

/* A checkbox that reads as a filter: the corpora to search in. */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--graphite);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.chip input { margin: 0; }
.chip:has(input:checked) { border-color: var(--ink); color: var(--ink); }
.chip:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.chip:has(input:disabled) { cursor: not-allowed; opacity: 0.5; }

/* A radio choice with a sentence of explanation: the two normativa search methods. */
.option {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

.option strong { display: block; font-size: 0.9375rem; font-weight: 600; line-height: 1.4; }
.option:has(input:checked) { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--hl); }

/* Tabs: underlined labels, the active one with the red mark. Links or role="tab" buttons. */
.tabs {
    display: flex;
    gap: 1.5rem;
    border-bottom: 1px solid var(--rule);
    overflow-x: auto;
    scrollbar-width: thin;
}

.tabs > a,
.tabs > button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0;
    border: 0;
    background: none;
    color: var(--graphite);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.tabs > a:hover, .tabs > button:hover { color: var(--ink); }

.tabs > [aria-current="page"],
.tabs > [aria-selected="true"] {
    box-shadow: inset 0 -4px 0 var(--hl);
    color: var(--ink);
}

/* 8 ── Tags, citations, highlight, margin note */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.05rem 0.45rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    color: var(--graphite);
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.6;
    text-transform: uppercase;
    white-space: nowrap;
}

.tag--ink { border-color: var(--ink); color: var(--ink); }
.tag--ok { border-color: var(--verifica); color: var(--verifica); }
.tag--warn { border-color: var(--attenzione); background: var(--attenzione-soft); color: var(--attenzione-text); }

/* Extremes of a decision or an act: a datum, not a paraphrase — set in mono. */
.cite {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* The highlighter. Only for the passage the reader was looking for. */
mark {
    padding: 0 0.15em;
    border-radius: 1px;
    background: var(--hl);
    color: var(--hl-ink);
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* Whatever sits in a mark takes its ink: a link's own light colour would vanish on the
   yellow in dark mode. */
mark * { color: inherit; }

/* The red pen in the margin: why a decision cited a norm, an editor's aside. */
.note {
    padding: 0.1rem 0 0.1rem 0.8rem;
    border-left: 2px solid var(--timbro);
    color: var(--graphite);
    font-family: var(--font-serif);
    font-size: 0.9375rem;
    font-style: italic;
    line-height: 1.5;
}

/* 9 ── Notices, loader, spinner, empty state */
.notice {
    padding: 0.75rem 1rem;
    border: 1px solid var(--rule-strong);
    border-left-width: 3px;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.875rem;
    line-height: 1.5;
}

.notice--warn { border-color: var(--attenzione); background: var(--attenzione-soft); }
.notice--ok { border-color: var(--verifica); background: var(--verifica-soft); }

/* The one loader of the site: lines of text, underlined in red one after the other.
   Markup: <div class="loader" role="status"><span class="loader__mark"></span>
   <p class="loader__msg">…</p></div>. The pages rotate the message. */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 3.5rem 1rem;
    text-align: center;
}

.loader__mark {
    position: relative;
    width: 3.5rem;
    height: 2.4rem;
    background:
        linear-gradient(var(--rule-strong), var(--rule-strong)) 0 0.3rem / 100% 2px no-repeat,
        linear-gradient(var(--rule-strong), var(--rule-strong)) 0 1.1rem / 78% 2px no-repeat,
        linear-gradient(var(--rule-strong), var(--rule-strong)) 0 1.9rem / 90% 2px no-repeat;
}

.loader__mark::after {
    position: absolute;
    left: 0;
    height: 3px;
    border-radius: 2px;
    background: var(--timbro);
    content: "";
    animation: loader-underline 2.7s ease-in-out infinite;
}

@keyframes loader-underline {
    0%   { top: 0.55rem; width: 0; }
    26%  { top: 0.55rem; width: 100%; }
    33%  { top: 1.35rem; width: 0; }
    59%  { top: 1.35rem; width: 78%; }
    66%  { top: 2.15rem; width: 0; }
    92%  { top: 2.15rem; width: 90%; }
    100% { top: 2.15rem; width: 90%; }
}

.loader__msg {
    max-width: 40ch;
    margin: 0;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-style: italic;
    line-height: 1.45;
    transition: opacity 0.25s ease;
}

/* The inline spinner: buttons, "loading the index…", tool activity. Takes currentColor. */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -0.15em;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
    padding: 2.5rem 1rem;
    color: var(--graphite);
    text-align: center;
}

.empty__title {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.25rem;
}

/* 10 ── Content pages: page head, prose, cards, steps, copy box, table, placeholder */
.page-head {
    padding-block: 3.5rem 2.5rem;
    border-bottom: 1px solid var(--rule);
}

.page-head h1 { max-width: 22ch; }

.kicker {
    margin: 0 0 0.75rem;
    color: var(--timbro);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lead {
    max-width: 62ch;
    color: var(--graphite);
    font-size: 1.1875rem;
    line-height: 1.55;
}

.prose {
    max-width: var(--measure);
    font-size: 1.0625rem;
    line-height: 1.7;
}

.prose h2 { margin-top: 2.75rem; }
.prose h3 { margin-top: 1.75rem; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: 0.4rem; }
.prose > :first-child { margin-top: 0; }

.card {
    padding: 1.5rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--surface);
}

.card > :last-child { margin-bottom: 0; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }

.steps > li {
    position: relative;
    padding-left: 2.4rem;
    counter-increment: step;
}

.steps > li + li { margin-top: 1rem; }

.steps > li::before {
    position: absolute;
    top: 0.1rem;
    left: 0;
    display: grid;
    width: 1.6rem;
    height: 1.6rem;
    place-items: center;
    border: 1px solid var(--ink);
    border-radius: 50%;
    content: counter(step);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.copybox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    padding: 0.35rem 0.35rem 0.35rem 0.75rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--paper-2);
}

.copybox code { min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 0.875rem; }

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }

.table th,
.table td {
    padding: 0.7rem 1rem 0.7rem 0;
    border-bottom: 1px solid var(--rule);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--graphite);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Counts. Mono is for identifiers; in figures its wide thousands separator reads "1 . 334". */
.num {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

/* A real screenshot of the product (brand.md §9.7), framed like a sheet of paper. */
.screenshot { margin: 0; }
.screenshot img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.screenshot figcaption { margin-top: 0.6rem; color: var(--graphite); font-size: 0.8125rem; }

/* A data flow (dati.html): who receives what, in order. An ordered list, so it reads in
   sequence without the drawing; the arrows are CSS. Across on wide screens, down on
   narrow ones. Markup: <ol class="flow"> alternating .flow__node (<strong> who, <span>
   what they do) and .flow__link (what passes); --none marks a step that never happens. */
.flow-figure { margin: 2.5rem 0; }
.flow-figure:last-child { margin-bottom: 0; }
.flow-figure h3 { margin-bottom: 0; }
.flow-figure figcaption { max-width: var(--measure); margin-top: 0.85rem; color: var(--graphite); font-size: 0.9375rem; }

.flow { display: flex; align-items: stretch; margin: 1rem 0 0; padding: 0; list-style: none; }

.flow__node {
    flex: 1 1 0;
    min-width: 0;
    padding: 1rem 1.1rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.flow__node strong { display: block; font-family: var(--font-serif); font-size: 1.125rem; font-weight: 500; }
.flow__node span { display: block; margin-top: 0.35rem; color: var(--graphite); font-size: 0.875rem; line-height: 1.45; }
.flow__node--none { border-style: dashed; background: transparent; }

.flow__link {
    display: flex;
    flex: 0 0 7.5rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.5rem;
    color: var(--graphite);
    font-size: 0.75rem;
    line-height: 1.35;
    text-align: center;
}

/* The arrow is drawing, not text: the "/ ''" alternative keeps screen readers quiet. */
.flow__link::after { content: "→"; content: "→" / ""; color: var(--timbro); font-size: 1.5rem; line-height: 1; }
.flow__link--none::after { color: var(--rule-strong); }

@media (max-width: 760px) {
    .flow { flex-direction: column; }
    .flow__link { flex-basis: auto; flex-direction: row; gap: 0.5rem; }
    .flow__link::after { content: "↓"; content: "↓" / ""; }
}

/* Content still to be written or supplied (photos, paragraphs, the video). Meant to be
   impossible to miss in review: search the HTML for class="placeholder". */
.placeholder {
    padding: 1rem 1.25rem;
    border: 1px dashed var(--attenzione);
    border-radius: var(--radius);
    background: var(--attenzione-soft);
    color: var(--ink);
    font-size: 0.9375rem;
}

.placeholder::before {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--attenzione-text);
    content: "Segnaposto";
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* 11 ── Search tools: the search card shared by giurisprudenza and normativa, so the two
   searches look like one tool with two corpora. */
.tool-hero { padding-block: 3.5rem 2rem; }
.tool-hero h1 { max-width: 20ch; margin-bottom: 1rem; }
.tool-hero .lead { margin: 0; }

.search-section { padding-block: 0 2rem; }

.search-card {
    padding: 0.5rem 1.5rem 1.5rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.search-tabs { margin-bottom: 1.1rem; }

.search-input {
    min-height: 3.25rem;
    padding: 0.75rem 1rem;
    font-size: 1.0625rem;
    resize: none;
}

.search-input::placeholder { transition: color 0.4s ease; }
.search-input.placeholder-fading::placeholder { color: transparent; }

.search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-top: 1rem;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.chip-group > .label { margin: 0 0.25rem 0 0; }

.chev { display: inline-block; transition: transform 0.15s ease; }
[aria-expanded="true"] > .chev { transform: rotate(180deg); }

.advanced-panel {
    margin-top: 1rem;
    border-top: 1px solid var(--rule);
}

.advanced-section { padding-block: 1.1rem 0.2rem; }

.advanced-section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.advanced-section__head h3 {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0;
}

.advanced-section__head p { margin: 0; color: var(--graphite); font-size: 0.8125rem; }

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem 1.25rem;
}

.advanced-grid .span-2 { grid-column: span 2; }
.advanced-grid .span-4 { grid-column: 1 / -1; }

.search-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.search-note { margin: 0 0 0 auto; color: var(--graphite); font-size: 0.8125rem; }

@media (max-width: 720px) {
    .search-card { padding-inline: 1rem; }
    .advanced-section__head { display: block; }
    .advanced-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .advanced-grid .span-2 { grid-column: 1 / -1; }
    .search-note { width: 100%; margin-left: 0; }
}

@media (max-width: 480px) {
    .advanced-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Documentation pages (guida, note legali): a table of contents beside the text. */
.doc-layout {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    gap: 3rem;
    align-items: start;
}

.toc {
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    font-size: 0.875rem;
}

.toc ol { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.toc a { color: var(--graphite); text-decoration: none; }
.toc a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--timbro); }

.doc-section { scroll-margin-top: calc(var(--header-h) + 1rem); }
.doc-section + .doc-section { margin-top: 3rem; padding-top: 2.5rem; border-top: 1px solid var(--rule); }
.doc-section > h2:first-child { margin-top: 0; }

/* Authentication pages use Clerk's maintained sign-in surface and only a small local
   form for product-specific name, legal acknowledgement and communication choices. */
.auth-page { background: var(--paper-2); }

.auth-page__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 28rem);
    gap: 3rem;
    align-items: start;
}

.auth-page__inner--narrow {
    display: block;
    max-width: 46rem;
}

.auth-page__intro { padding-top: 1.5rem; }
.clerk-auth-mount { min-height: 28rem; }

.auth-form {
    display: grid;
    gap: 1.25rem;
    margin-top: 1.5rem;
    padding: 1.5rem;
}

.auth-form + .auth-form { margin-top: 1rem; }
.auth-form h2 { margin-bottom: 0; font-size: 1.35rem; }
.auth-form .btn { justify-self: start; }
.auth-choice { align-items: flex-start; }
.auth-choice input { margin-top: 0.3rem; }

.account-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 0;
    padding: 1.25rem 1.5rem;
}

.account-summary div { min-width: 0; }
.account-summary dt { color: var(--graphite); font-size: 0.75rem; text-transform: uppercase; }
.account-summary dd { margin: 0.25rem 0 0; overflow-wrap: anywhere; font-weight: 500; }

.account-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
}

.account-delete-dialog {
    width: min(36rem, calc(100% - 2rem));
    max-height: calc(100dvh - 2rem);
    padding: 0;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.account-delete-dialog::backdrop { background: var(--backdrop); }
.account-delete-dialog .auth-form { margin: 0; }
.account-delete-dialog p { margin: 0; }
.account-delete-dialog .account-actions { margin-top: 0; }

@media (max-width: 760px) {
    .auth-page__inner { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
    .auth-page__intro { padding-top: 0; }
    .account-summary { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
    .toc { position: static; padding: 1rem 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius); }
}

/* A live status line: the check of the assistant connector. */
.status { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--graphite); font-size: 0.8125rem; }
.status__dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--rule-strong); }
.status.online { color: var(--verifica); }
.status.online .status__dot { background: var(--verifica); }
.status.offline { color: var(--attenzione-text); }
.status.offline .status__dot { background: var(--attenzione); }

/* People: real photos, a name and a role (brand.md §9.7: faces, not corporate portraits). */
.people {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
    gap: 2rem 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.person img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius);
    background: var(--paper-2);
    object-fit: cover;
}

.person strong { display: block; margin-top: 0.75rem; font-family: var(--font-serif); font-size: 1.125rem; font-weight: 500; }
.person span { display: block; color: var(--graphite); font-size: 0.875rem; line-height: 1.45; }
.person span + span { margin-top: 0.4rem; color: var(--ink); }

/* A row of source links under a claim: where to check it. */
.link-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.9rem;
    margin: 0.75rem 0 0;
    padding: 0;
    color: var(--graphite);
    font-size: 0.8125rem;
    list-style: none;
}

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

.muted { color: var(--graphite); }
.small { font-size: 0.8125rem; }
.mono { font-family: var(--font-mono); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    .site-header, .site-footer { display: none !important; }
}
