/* ============================================================
   Italian Tech Theme — base stylesheet
   Mobile-first: base = mobile, enhance with min-width queries
   Colors: Italian flag (green #009246, white, red #ce2b37)
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    /* Brand palette */
    --green:        #009246;
    --green-dark:   #006e35;
    --green-light:  #00b857;
    --green-subtle: rgba(0, 146, 70, 0.07);
    --green-border: rgba(0, 146, 70, 0.18);

    --red:          #ce2b37;
    --red-dark:     #9e1e28;
    --red-subtle:   rgba(206, 43, 55, 0.07);
    --red-border:   rgba(206, 43, 55, 0.18);

    /* Surface */
    --bg:           #ffffff;
    --bg-2:         #f7fdf9;
    --bg-3:         #eef9f3;
    --surface:      #ffffff;
    --surface-2:    #f7fdf9;

    /* Typography */
    --text:         #1a2922;
    --text-muted:   #4a6355;
    --text-light:   #7a9488;

    /* Borders & shadows */
    --border:       rgba(0, 146, 70, 0.14);
    --border-light: rgba(0, 146, 70, 0.08);
    --shadow-sm:    0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-md:    0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg:    0 8px 32px rgba(0, 0, 0, 0.10);

    /* Layout */
    --container:    1200px;
    --radius-sm:    4px;
    --radius-md:    8px;
    --radius-lg:    12px;

    /* Nav */
    --nav-height:   52px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text);
    background-color: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img, video, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--green);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--green-dark);
}

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

.page-body {
    flex: 1;
}

/* ── Italian flag accent bar ────────────────────────────────── */
.flag-bar {
    height: 4px;
    background: linear-gradient(90deg,
        var(--green) 0%,
        var(--green) 33.33%,
        #ffffff 33.33%,
        #ffffff 66.66%,
        var(--red) 66.66%,
        var(--red) 100%
    );
    position: fixed;
    left: 0;
    right: 0;
}

.flag-bar--top { position: sticky; top: 0; z-index: 200; }

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 4px;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    transition: box-shadow 0.25s ease;
}

@supports (animation-timeline: scroll()) {
    @keyframes navbar-shadow {
        from { box-shadow: none; }
        to   { box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 6px rgba(0,0,0,0.05); }
    }
    .navbar {
        animation: navbar-shadow linear both;
        animation-timeline: scroll();
        animation-range: 0px 1px;
    }
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    height: 100%;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-brand:hover { color: var(--green); }

.navbar-brand-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
}

.navbar-logo-img {
    height: 32px;
    width: auto;
    display: block;
}

/* Mobile nav toggle — visible by default, hidden on tablet+ */
.navbar-toggle {
    display: block;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
}

.navbar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.navbar-toggle span + span { margin-top: 5px; }

/* Nav collapse — hidden dropdown on mobile, inline on tablet+ */
.navbar-collapse {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    z-index: 99;
}

.nav-toggle-input { display: none; }
#nav-toggle:checked ~ .navbar-collapse { display: flex; }

.navbar-nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    list-style: none;
    width: 100%;
}

.navbar-nav a {
    display: block;
    width: 100%;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s;
}

.navbar-nav a:hover,
.navbar-nav a.active { color: var(--green); }

/* ── Language switcher ──────────────────────────────────────── */
.lang-switcher {
    position: relative;
    margin-top: 0.75rem;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    white-space: nowrap;
}

.lang-btn:hover {
    border-color: var(--green-border);
    color: var(--green);
    background: var(--green-subtle);
}

.lang-globe {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
}

.lang-chevron {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.lang-switcher:focus-within .lang-chevron { transform: rotate(180deg); }

.lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 130px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    list-style: none;
    overflow: hidden;
    z-index: 300;
}

.lang-switcher:focus-within .lang-dropdown { display: block; }

.lang-dropdown li a {
    display: block;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.lang-dropdown li a:hover { background: var(--green-subtle); color: var(--green-dark); }

.lang-dropdown li a.active {
    color: var(--green-dark);
    font-weight: 700;
    background: var(--green-subtle);
}

/* Mobile: show as a flat row of links, not dropdown */
@media (max-width: 767px) {
    .lang-switcher { margin-top: 0.5rem; }
    .lang-btn { display: none; }
    .lang-dropdown {
        display: flex;
        position: static;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--border-light);
        border-radius: 0;
        flex-wrap: wrap;
        gap: 0;
        min-width: 0;
        padding: 0.25rem 0;
    }
    .lang-dropdown li a {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}

.navbar-cta {
    display: inline-flex;
    align-items: center;
    margin-top: 0.75rem;
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff !important;
    background: var(--green);
    transition: background 0.2s, box-shadow 0.2s;
}

.navbar-cta:hover {
    background: var(--green-dark);
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(0, 146, 70, 0.3);
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); margin-top: 3rem; margin-bottom: 1rem; }
h3 { font-size: 1.35rem; margin-top: 2rem; margin-bottom: 0.75rem; }
h4 { font-size: 1.125rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

h2 {
    padding-left: 0.75rem;
    border-left: 3px solid var(--green);
}

p {
    margin-bottom: 1.25rem;
    color: var(--text-muted);
}

ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1.25rem;
}

li { margin-bottom: 0.4rem; }

blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--green);
    background: var(--green-subtle);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-muted);
    font-style: italic;
}

code {
    font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
    font-size: 0.875em;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.1em 0.35em;
    color: var(--green-dark);
}

pre {
    background: #f2faf5;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    position: relative;
}

pre::before {
    content: "";
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--green), var(--red));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    position: absolute;
    top: 0; left: 0; right: 0;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
    font-size: 0.9rem;
}

table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

th {
    background: var(--green-subtle);
    border-bottom: 2px solid var(--green-border);
    padding: 0.6rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--green-dark);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-muted);
    vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--green-subtle); }

hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 2rem 0;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.btn-primary:hover {
    background: var(--green-dark);
    border-color: var(--green-dark);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 146, 70, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--red);
    border-color: var(--red);
}

.btn-secondary:hover {
    background: var(--red);
    color: #fff;
    box-shadow: 0 4px 16px rgba(206, 43, 55, 0.25);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-outline:hover {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-subtle);
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--green-border);
}

/* ── Feature cards (landing features section) ───────────────── */
.features-grid { counter-reset: feature-counter; }

.feature-card {
    position: relative;
    overflow: hidden;
    counter-increment: feature-counter;
}

/* Green gradient accent bar at top */
.feature-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--green), #5cb85c);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    opacity: 0.6;
    transition: opacity 0.22s ease;
}

/* Faint sequential number watermark */
.feature-card::after {
    content: counter(feature-counter, decimal-leading-zero);
    position: absolute;
    bottom: 0.25rem;
    right: 0.75rem;
    font-size: 3.5rem;
    font-weight: 900;
    line-height: 1;
    color: var(--green);
    opacity: 0.055;
    pointer-events: none;
    user-select: none;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    transition: opacity 0.22s ease;
}

.feature-card:hover::before { opacity: 1; }
.feature-card:hover::after  { opacity: 0.18; color: var(--green); transition: opacity 0.22s ease, color 0.22s ease; }

.feature-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.feature-card-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
    position: relative;
    z-index: 1;
}

/* ── Sections ───────────────────────────────────────────────── */
.section        { padding-block: 2.5rem; }
.section-sm     { padding-block: 1.5rem; }
.section-alt    { background: var(--bg-2); }

.section-title {
    font-size: clamp(1.75rem, 3.5vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 0.75rem;
    border-left: none;
    padding-left: 0;
}

.section-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.section-header { margin-bottom: 2rem; }

/* Italian tricolor gradient text */
.gradient-text {
    background: linear-gradient(135deg, var(--green) 0%, #1a6640 50%, var(--red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Grid utilities (mobile: 1 col, expand at breakpoints) ─── */
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* ── Badge ──────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-green {
    background: var(--green-subtle);
    color: var(--green-dark);
    border: 1px solid var(--green-border);
}

.badge-red {
    background: var(--red-subtle);
    color: var(--red-dark);
    border: 1px solid var(--red-border);
}

/* ── Divider with Italian tricolor ──────────────────────────── */
.divider-flag {
    height: 2px;
    background: linear-gradient(90deg,
        var(--green) 0%, var(--green) 33%,
        transparent 33%, transparent 66%,
        var(--red) 66%, var(--red) 100%
    );
    margin-block: 2rem;
    opacity: 0.5;
}

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
    border-top: 1px solid var(--border);
    padding-block: 2rem;
    margin-top: auto;
    background: var(--bg-2);
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.footer-brand { font-weight: 700; color: var(--text); }

.footer-copy { font-size: 0.875rem; color: var(--text-light); }

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    list-style: none;
}

.footer-links a { font-size: 0.875rem; color: var(--text-muted); }
.footer-links a:hover { color: var(--green); }

/* ── Pretty link card ───────────────────────────────────────── */
.pretty-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    margin: 1rem 0;
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: var(--radius-lg);
    background: var(--bg);
    text-decoration: none;
    color: var(--text);
    transition: background 0.2s, box-shadow 0.2s, transform 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.pretty-link::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--green-subtle) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.pretty-link:hover {
    border-color: var(--green-border);
    border-left-color: var(--green-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    color: var(--text);
}

.pretty-link:hover::before { opacity: 1; }

.pretty-link-thumb {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-3);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pretty-link-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.pretty-link-body {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.pretty-link-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 0.2rem;
}

.pretty-link-arrow {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    color: var(--green);
    opacity: 0.8;
    margin-left: 0.1rem;
}

.pretty-link-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0.2rem 0 0.3rem;
}

.pretty-link-url {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    letter-spacing: 0.01em;
}

/* ── Blocks shortcode ───────────────────────────────────────── */

/* Grid layout */
.blocks-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin: 2rem 0;
    counter-reset: block-counter;
}

@media (min-width: 540px) {
    .blocks-grid--2,
    .blocks-grid--3,
    .blocks-grid--4,
    .blocks-grid--5,
    .blocks-grid--6 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
    .blocks-grid--3 { grid-template-columns: repeat(3, 1fr); }
    .blocks-grid--4 { grid-template-columns: repeat(4, 1fr); }
    .blocks-grid--5 { grid-template-columns: repeat(5, 1fr); }
    .blocks-grid--6 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
    .blocks-grid--6 { grid-template-columns: repeat(6, 1fr); }
}

/* Card */
.block-card {
    position: relative;
    padding: 1.5rem 1.25rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
    transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
    counter-increment: block-counter;
}

/* Green accent bar at top of card */
.block-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--green), #5cb85c);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    opacity: 0.65;
    transition: opacity 0.22s ease;
}

/* Faint sequential number watermark */
.block-card::after {
    content: counter(block-counter, decimal-leading-zero);
    position: absolute;
    bottom: 0.25rem;
    right: 0.75rem;
    font-size: 3.5rem;
    font-weight: 900;
    line-height: 1;
    color: var(--green);
    opacity: 0.055;
    pointer-events: none;
    user-select: none;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.block-card:hover {
    box-shadow: 0 6px 24px rgba(0, 146, 70, 0.12), 0 2px 8px rgba(0,0,0,0.06);
    transform: translateY(-3px);
    border-color: var(--green-border);
}

.block-card:hover::before { opacity: 1; }

.block-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    margin: 0;
    position: relative;
    z-index: 1;
}

.block-card-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
    position: relative;
    z-index: 1;
}

.block-card-body {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

.block-card-body p { margin: 0.25rem 0 0; }

/* Line layout */
.blocks-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 1.5rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.block-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
}

.block-row:last-child { border-bottom: none; }
.block-row:hover { background: var(--bg-2); }

.block-row-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--green-dark);
    flex-shrink: 0;
}

.block-row-title::after { content: " —"; color: var(--text-light); font-weight: 400; }

.block-row-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.55;
}

/* ── Prose (article body) ───────────────────────────────────── */
.prose { max-width: 72ch; }

.prose h2 {
    padding-left: 0.75rem;
    border-left: 3px solid var(--green);
}

/* ── Sidebar layout (mobile: off-screen drawer) ─────────────── */
.with-sidebar { display: block; }

.sidebar {
    position: fixed;
    top: calc(var(--nav-height) + 4px);
    left: -280px;
    width: 260px;
    height: calc(100vh - var(--nav-height) - 4px);
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--bg);
    padding: 1.5rem 0 2rem;
    z-index: 150;
    transition: left 0.25s ease;
    box-shadow: var(--shadow-lg);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-toggle-input { display: none; }
#sidebar-toggle:checked ~ .page-body .sidebar { left: 0; }

.sidebar-main { min-width: 0; }

/* Floating open button — visible on mobile */
.sidebar-open-btn {
    display: inline-flex;
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    z-index: 90;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 146, 70, 0.35);
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s;
}

.sidebar-open-btn:hover { background: var(--green-dark); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 149;
}

#sidebar-toggle:checked ~ .page-body .sidebar-overlay { display: block; cursor: pointer; }

/* Nav tree inside sidebar */
.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-section-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-light);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    margin-top: 0.5rem;
}

.sidebar-section-link:hover {
    color: var(--green);
    background: var(--green-subtle);
    border-left-color: var(--green-border);
}

.sidebar-section-link.active {
    color: var(--green-dark);
    border-left-color: var(--green);
    background: var(--green-subtle);
}

.sidebar-page-link {
    display: block;
    padding: 0.35rem 1.25rem 0.35rem 2rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    line-height: 1.4;
}

.sidebar-page-link:hover {
    color: var(--green);
    background: var(--green-subtle);
    border-left-color: var(--green-border);
}

.sidebar-page-link.active {
    color: var(--green-dark);
    font-weight: 600;
    border-left-color: var(--green);
    background: var(--green-subtle);
}

/* Collapsible section groups */
.sidebar-group { list-style: none; }

.sidebar-group > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group > summary::marker { display: none; }

.sidebar-group > summary a {
    flex: 1;
    color: inherit;
    text-decoration: none;
}

.sidebar-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-right: 1rem;
    position: relative;
    opacity: 0.5;
}

.sidebar-chevron::before,
.sidebar-chevron::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 6px;
    height: 1.5px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.18s ease;
}

.sidebar-chevron::before { left: 1px;  transform: translateY(-50%) rotate( 45deg); }
.sidebar-chevron::after  { right: 1px; transform: translateY(-50%) rotate(-45deg); }

.sidebar-group[open] > summary .sidebar-chevron::before { transform: translateY(-50%) rotate(-45deg); }
.sidebar-group[open] > summary .sidebar-chevron::after  { transform: translateY(-50%) rotate( 45deg); }

.sidebar-children {
    padding-left: 0.5rem;
    border-left: 1px solid var(--border-light);
    margin-left: 1.25rem;
    margin-top: 0.15rem;
    margin-bottom: 0.25rem;
}

/* ============================================================
   Responsive — mobile-first breakpoints
   ============================================================ */

/* ── Tablet: 768px+ ─────────────────────────────────────────── */
@media (min-width: 768px) {
    .container { padding-inline: 1.5rem; }

    /* Navbar: switch to inline horizontal layout */
    .navbar-toggle { display: none; }

    .navbar-collapse {
        display: flex;
        position: static;
        background: none;
        border: none;
        padding: 0;
        flex-direction: row;
        align-items: stretch;
        align-self: stretch;
        gap: 1rem;
        height: 100%;
        z-index: auto;
    }

    .navbar-inner { gap: 2rem; }

    .navbar-nav {
        flex-direction: row;
        align-items: stretch;
        gap: 0;
        width: auto;
        height: 100%;
    }

    .navbar-nav li {
        display: flex;
        align-items: stretch;
    }

    .navbar-nav a {
        display: flex;
        align-items: center;
        height: 100%;
        width: auto;
        padding: 0 0.75rem;
        border-radius: var(--radius-sm);
        transition: color 0.2s, background 0.2s;
    }

    /* Lang switcher must self-center since collapse no longer does it */
    .lang-switcher {
        display: flex;
        align-items: center;
    }

    .navbar-nav a:hover,
    .navbar-nav a.active {
        background: var(--green-subtle);
    }

    .navbar-cta { margin-top: 0; }

    /* Lang switcher: restore dropdown mode on desktop */
    .lang-switcher { margin-top: 0; }
    .lang-btn { display: flex; }
    .lang-dropdown {
        display: none;
        position: absolute;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        flex-wrap: nowrap;
        flex-direction: column;
        padding: 0;
    }
    .lang-switcher:focus-within .lang-dropdown { display: block; }

    /* Grids: 2 columns */
    .grid-2 { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }

    /* Sections: medium padding */
    .section    { padding-block: 4rem; }
    .section-sm { padding-block: 2.5rem; }

    .section-subtitle { font-size: 1.125rem; max-width: 600px; margin-bottom: 3rem; }
    .section-header   { margin-bottom: 3rem; }

    .card { padding: 1.5rem; }

    .divider-flag { margin-block: 3rem; }

    /* Footer: horizontal */
    .footer-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }

    .footer-links { justify-content: flex-start; }
}

/* ── Sidebar breakpoint: 900px+ ─────────────────────────────── */
@media (min-width: 900px) {
    /* Sidebar becomes a sticky desktop panel */
    .with-sidebar {
        display: flex;
        align-items: flex-start;
        min-height: calc(100vh - var(--nav-height) - 4px);
    }

    .sidebar {
        position: sticky;
        left: 0;
        top: calc(var(--nav-height) + 4px);
        height: calc(100vh - var(--nav-height) - 4px);
        box-shadow: none;
        transition: none;
        flex-shrink: 0;
        z-index: auto; /* reset mobile z-index:150 — must stay below navbar */
    }

    .sidebar-main { flex: 1; }

    /* Hide the floating open button and overlay — never needed on desktop */
    .sidebar-open-btn { display: none; }
    .sidebar-overlay  { display: none !important; }

    /* 3-column grid */
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Desktop: 1024px+ ───────────────────────────────────────── */
@media (min-width: 1024px) {
    /* Full 4-column grid */
    .grid-4 { grid-template-columns: repeat(4, 1fr); }

    /* Full section padding */
    .section    { padding-block: 5rem; }
    .section-sm { padding-block: 3rem; }
}

/* ── Large desktop: 1440px+ ─────────────────────────────────── */
@media (min-width: 1440px) {
    html { font-size: 17px; }
}
