:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", Arial, sans-serif;

    --page-background: #fbfbfc;
    --surface: #ffffff;
    --surface-soft: #f7f6fa;

    --primary: #66568f;
    --primary-hover: #55457d;
    --primary-soft: #eeeaf7;

    --text: #24232a;
    --muted: #72717b;
    --border: #dedde5;

    --danger: #a33b3b;
    --danger-background: #fff2f2;

    --shadow-small: 0 6px 18px rgba(38, 34, 52, 0.07);
    --shadow-medium: 0 12px 30px rgba(38, 34, 52, 0.09);

    background: var(--page-background);
    color: var(--text);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
            radial-gradient(
                    circle at 50% 0,
                    rgba(102, 86, 143, 0.045),
                    transparent 440px
            ),
            var(--page-background);
}

/* Contenitore principale */

.generator-shell {
    width: 100%;
    min-height: 100vh;
    padding: clamp(2rem, 6vw, 5rem) 1.25rem;
}

.generator-card {
    width: min(1000px, 100%);
    margin: 0 auto;
}

/* Intestazione */

.generator-card > header {
    margin-bottom: clamp(2rem, 5vw, 3.5rem);
    padding-left: clamp(1rem, 3vw, 1.75rem);
    border-left: 2px solid rgba(102, 86, 143, 0.45);
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: #44424a;
    font-size: 0.88rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--primary);
    font-size: clamp(2.25rem, 5vw, 3.8rem);
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.035em;
}

.intro {
    max-width: 700px;
    margin: 0.85rem 0 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

/* Stati di caricamento ed errore */

.status {
    margin-bottom: 1.25rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--muted);
    box-shadow: var(--shadow-small);
}

.status-error {
    border-color: #e8bcbc;
    background: var(--danger-background);
    color: var(--danger);
}

/* Form */

form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: clamp(1.2rem, 3vw, 2rem);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-medium);
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 1.15rem;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
}

fieldset:nth-of-type(3) {
    grid-column: 1 / -1;
}

legend {
    padding: 0 0.45rem;
    color: #34323a;
    font-size: 0.92rem;
    font-weight: 650;
}

/* Radio e checkbox */

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

.choice-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-grid label,
.author-options label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: #34323a;
    font-size: 0.92rem;
    cursor: pointer;
    transition:
            border-color 160ms ease,
            background-color 160ms ease,
            box-shadow 160ms ease,
            transform 160ms ease;
}

.choice-grid label:hover,
.author-options label:hover {
    border-color: rgba(102, 86, 143, 0.55);
    background: var(--primary-soft);
}

.choice-grid label:has(input:checked),
.author-options label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px var(--primary);
}

input[type="checkbox"],
input[type="radio"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--primary);
}

/* Ricerca autrici */

.search-label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.84rem;
}

.search-input {
    width: 100%;
    min-height: 46px;
    margin-bottom: 0.85rem;
    padding: 0.72rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition:
            border-color 160ms ease,
            box-shadow 160ms ease;
}

.search-input::placeholder {
    color: #96949d;
}

.search-input:hover {
    border-color: #c4c1cd;
}

.search-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 86, 143, 0.13);
}

.author-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    max-height: 240px;
    padding-right: 0.35rem;
    overflow-y: auto;
    scrollbar-color: #c9c6d2 transparent;
    scrollbar-width: thin;
}

/* Range */

input[type="range"] {
    width: 100%;
    margin: 0.8rem 0 0.25rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 0.1rem;
    color: var(--muted);
    font-size: 0.78rem;
}

output {
    color: var(--primary);
}

/* Risultati */

.results-count {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    background: var(--surface-soft);
    color: #45424b;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Pulsanti */

.actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.25rem;
}

.button {
    min-width: 145px;
    min-height: 46px;
    padding: 0.72rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 650;
    letter-spacing: 0.025em;
    cursor: pointer;
    transition:
            background-color 160ms ease,
            border-color 160ms ease,
            color 160ms ease,
            box-shadow 160ms ease,
            transform 160ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 5px 14px rgba(102, 86, 143, 0.2);
}

.button-primary:hover:not(:disabled) {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.button-secondary {
    border-color: var(--border);
    background: #ffffff;
    color: #4a4652;
}

.button-secondary:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
    box-shadow: none;
}

/* Accessibilità */

:focus-visible {
    outline: 3px solid rgba(102, 86, 143, 0.28);
    outline-offset: 2px;
}

/* Tablet */

@media (max-width: 760px) {
    form {
        grid-template-columns: 1fr;
    }

    fieldset:nth-of-type(3),
    .results-count,
    .actions {
        grid-column: auto;
    }

    .author-options {
        grid-template-columns: 1fr;
    }
}

/* Smartphone */

@media (max-width: 560px) {
    .generator-shell {
        padding: 2rem 0.9rem;
    }

    .generator-card > header {
        padding-left: 1rem;
    }

    form {
        padding: 1rem;
        border-radius: 12px;
    }

    .choice-grid,
    .choice-grid-three {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column-reverse;
    }

    .actions .button {
        width: 100%;
    }
}