/* ==========================================================================
   MY FILM LIST — Foglio di stile (v15, consolidato)
   ========================================================================== */

/* ---------- 1. Variabili ---------- */
:root {
    --ink: #20252c;
    --muted: #727984;
    --paper: #f8f8f5;
    --card: #ffffff;
    --line: #e8e9e6;
    --accent: #e96f4d;
    --accent-dark: #ca5334;
    --olive: #68715c;
    --soft-orange: #fff1eb;
    --shadow: 0 20px 60px rgba(39, 44, 50, 0.08);
    --ease-smooth: cubic-bezier(0.32, 0.72, 0, 1);
    --ease-out-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --dur-fast: 220ms;
    --dur-base: 320ms;
    --dur-slow: 480ms;
}

/* ---------- 2. Reset e base ---------- */
* { box-sizing: border-box; }
html { height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 4%, rgba(233, 111, 77, 0.10), transparent 24rem),
        var(--paper);
    font-family: "DM Sans", sans-serif;
}
@supports (min-height: 100dvh) {
    body { min-height: 100dvh; }
}

h1, h2, h3, p { margin-top: 0; }
h1 {
    font-family: "Playfair Display", serif;
    font-size: clamp(44px, 7vw, 74px);
    line-height: .98;
    letter-spacing: -.045em;
    margin-bottom: 16px;
}
h1 span { color: var(--accent); font-style: italic; }
h2 {
    font-family: "Playfair Display", serif;
    font-size: 28px;
    letter-spacing: -.025em;
    margin: 0;
}

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

/* ---------- 3. Layout generale ---------- */
.page-shell {
    max-width: 1160px;
    margin: 0 auto;
    padding: 58px 28px 35px;
}
.hero { text-align: center; margin-bottom: 48px; }

.brand-mark {
    display: grid; place-items: center;
    width: 42px; height: 42px;
    margin: 0 auto 20px;
    color: white;
    background: var(--accent);
    border-radius: 13px;
    font-size: 20px;
    box-shadow: 0 8px 20px rgba(233, 111, 77, .25);
}
.eyebrow, .section-label {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    margin: 0 0 11px;
}
.hero-copy { color: var(--muted); font-size: 16px; margin: 0; }

footer {
    color: #aeb1ad;
    font-size: 9px;
    letter-spacing: .18em;
    text-align: center;
    margin-top: 58px;
}
footer span { color: var(--accent); padding: 0 7px; }

@supports (padding: max(0px)) {
    .page-shell {
        padding-left: max(18px, env(safe-area-inset-left));
        padding-right: max(18px, env(safe-area-inset-right));
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
}

/* ---------- 4. Card generiche e headings ---------- */
.card, .empty-state {
    background: var(--card);
    border: 1px solid rgba(31, 37, 44, .05);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.form-card { padding: 30px 34px 34px; }

.section-heading, .list-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.section-heading { margin-bottom: 29px; }
.list-heading { align-items: end; margin-bottom: 21px; padding: 0 4px; }

.list-heading-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.clapper-icon {
    display: grid; place-items: center;
    width: 39px; height: 32px;
    color: var(--accent);
    background: var(--soft-orange);
    border-radius: 9px;
    font-size: 17px;
    transform: rotate(-7deg);
}
.count {
    display: inline-grid; place-items: center;
    min-width: 27px; height: 27px;
    margin-left: 5px;
    color: var(--accent);
    background: var(--soft-orange);
    border-radius: 50%;
    font: 700 12px "DM Sans", sans-serif;
    vertical-align: 3px;
}
.reel-decoration { display: flex; gap: 5px; padding-bottom: 6px; }
.reel-decoration i {
    display: block; width: 6px; height: 6px;
    background: #d8dbd5; border-radius: 50%;
}

.empty-state { padding: 56px 25px; text-align: center; }
.empty-icon { color: var(--accent); font-size: 42px; margin-bottom: 10px; }
.empty-state h3 {
    font-family: "Playfair Display", serif;
    font-size: 23px;
    margin-bottom: 8px;
}
.empty-state p { color: var(--muted); font-size: 14px; margin-bottom: 0; }

/* ---------- 5. Form di aggiunta/modifica ---------- */
.title-form {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr .9fr auto auto;
    grid-template-areas:
        "title title title title details"
        "state state rating add clear";
    gap: 13px;
    align-items: end;
    max-width: 900px;
}
.field-title { grid-area: title; }
.state-field { grid-area: state; }
.rating-field { grid-area: rating; }
.title-form > .primary-button { grid-area: add; }
.details-form-btn { grid-area: details; }
.clear-form-btn { grid-area: clear; }
.field label {
    display: block;
    color: #505660;
    font-size: 12px;
    font-weight: 700;
    margin: 0 0 8px;
}
.field label span { color: var(--muted); font-weight: 400; }

input, select, textarea {
    width: 100%;
    padding: 0 13px;
    color: var(--ink);
    background: #fbfbfa;
    border: 1px solid var(--line);
    border-radius: 9px;
    font: inherit;
    font-size: 13px;
    outline: none;
    transition:
        border-color var(--dur-base) var(--ease-out-soft),
        box-shadow var(--dur-base) var(--ease-out-soft),
        background var(--dur-base) var(--ease-out-soft);
}
input, select { height: 46px; }
input::placeholder { color: #a7abb0; }
input:focus, select:focus, textarea:focus {
    background: white;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, .13);
}

.state-field { min-width: 130px; }
.field-notes { grid-column: 1 / -1; }
.field-notes textarea {
    padding: 10px 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 70px;
}
.field-watched { grid-column: 1 / -1; }
.field-watched input { max-width: 220px; }

.form-buttons {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

/* ---------- 6. Stepper del voto (form) ---------- */
.rating-input {
    display: flex;
    align-items: stretch;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 9px;
    overflow: hidden;
    background: #fbfbfa;
    transition:
        border-color var(--dur-base) var(--ease-out-soft),
        box-shadow var(--dur-base) var(--ease-out-soft);
}
.rating-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, .13);
    background: white;
}
.rating-input input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    color: var(--accent);
}
.rating-input input:focus { box-shadow: none; }
.rating-btn {
    display: grid;
    place-items: center;
    width: 36px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font: 700 20px "DM Sans", sans-serif;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--dur-fast) ease;
}
.rating-btn:hover { background: var(--soft-orange); }
.rating-btn:active { background: var(--accent); color: white; }

/* ---------- 7. Bottoni principali ---------- */
.primary-button {
    height: 46px;
    padding: 0 17px;
    border: 0;
    border-radius: 9px;
    color: white;
    background: var(--accent);
    font: 700 13px "DM Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.primary-button span {
    font-size: 21px;
    font-weight: 400;
    line-height: 0;
    vertical-align: -2px;
    margin-right: 4px;
}
.primary-button:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 7px 15px rgba(233, 111, 77, .22);
}

.logout-btn {
    padding: 7px 14px;
    color: var(--accent);
    background: var(--soft-orange);
    border: 0;
    border-radius: 8px;
    font: 600 12px "DM Sans", sans-serif;
    cursor: pointer;
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        color var(--dur-fast) var(--ease-out-soft);
}
.logout-btn:hover { background: var(--accent); color: white; }

.cancel-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0 24px;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 9px;
    font: 600 13px "DM Sans", sans-serif;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background var(--dur-fast) ease,
        color var(--dur-fast) ease,
        border-color var(--dur-fast) ease;
}
.cancel-button:hover {
    background: #f5f5f3;
    color: var(--ink);
    border-color: #d5d5d0;
}
.cancel-button:visited { color: var(--muted); }

.force-save-btn {
    padding: 9px 16px;
    background: #e8a83c;
    color: white;
    border: 0;
    border-radius: 8px;
    font: 700 12px "DM Sans", sans-serif;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out-soft);
}
.force-save-btn:hover { background: #c88e1f; }

.rec-add-btn {
    width: 100%;
    padding: 10px 12px;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 9px;
    font: 700 12px "DM Sans", sans-serif;
    cursor: pointer;
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth);
}
.rec-add-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }

.watched-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 14px;
    height: 38px;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 9px;
    font: 700 12px "DM Sans", sans-serif;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(233, 111, 77, 0.22);
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.watched-btn:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(233, 111, 77, 0.32);
}
.watched-btn svg { flex-shrink: 0; }

.backfill-link {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.backfill-link:hover { background: var(--soft-orange); color: var(--accent); }

.back-to-list-wrap {
    display: flex;
    justify-content: center;
    margin-top: 42px;
    padding-bottom: 10px;
}
.back-to-list {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 46px;
    padding: 0 24px;
    color: var(--accent);
    background: var(--soft-orange);
    border: 1px solid #f0c4b6;
    border-radius: 10px;
    font: 700 13px "DM Sans", sans-serif;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        color var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.back-to-list:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 7px 15px rgba(233, 111, 77, .25);
}

/* ---------- 8. Icon buttons (azioni sulle card) ---------- */
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid #e8e9e6;
    border-radius: 8px;
    color: #a2a6aa;
    cursor: pointer;
    text-decoration: none;
    flex: 0 0 auto;
    min-width: 0;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    transition:
        background var(--dur-fast) ease,
        color var(--dur-fast) ease,
        border-color var(--dur-fast) ease,
        transform var(--dur-fast) ease;
}
.icon-btn svg { display: block; width: 15px; height: 15px; }
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn-edit:hover { background: #fff5f2; color: var(--accent); border-color: #f0c4b6; }
.icon-btn-delete:hover { background: #fff5f2; color: #c54d39; border-color: #f0b3a6; }
.icon-btn-recommend { color: #80654d; border-color: #e6d8c4; }
.icon-btn-recommend:hover { background: #fff8ec; color: #a07000; border-color: #f0dba8; }
.icon-btn-watched { color: #7a8078; border-color: #e5e6e4; }
.icon-btn-watched:hover {
    background: #f0f7ef;
    color: #4f7a4f;
    border-color: #c7dcc7;
}
.title-item.is-to-watch .icon-btn-watched {
    color: var(--accent);
    border-color: #f0c4b6;
    background: #fff8f5;
}
.title-item.is-to-watch .icon-btn-watched:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ---------- 9. User bar e Stats toggle ---------- */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--muted);
}
.user-info { display: flex; align-items: center; gap: 14px; }
.user-bar strong { color: var(--ink); }

.stats-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 10px;
    font: 700 11px "DM Sans", sans-serif;
    letter-spacing: .14em;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(233, 111, 77, .28);
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.stats-toggle:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(233, 111, 77, .35);
}
.stats-toggle.active {
    background: var(--accent-dark);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, .15);
}
.stats-icon { display: block; flex-shrink: 0; width: 16px; height: 16px; }

/* ---------- 10. Alert e avvisi ---------- */
.alerts { display: grid; gap: 9px; margin: -20px 0 22px; }
.alert {
    padding: 13px 16px;
    border-radius: 9px;
    font-size: 13px;
    animation: slideDown var(--dur-base) var(--ease-smooth) backwards;
}
.alert:nth-child(2) { animation-delay: 60ms; }
.alert:nth-child(3) { animation-delay: 120ms; }
.alert-success { color: #386045; background: #eaf5eb; }
.alert-error { color: #964432; background: #ffede8; }

.force-warning {
    background: #fff8e6;
    border: 1px solid #f5d88a;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 22px;
    font-size: 13px;
    color: #6b4e00;
    line-height: 1.5;
    animation: slideDown var(--dur-base) var(--ease-smooth) backwards;
}
.force-warning p { margin: 0 0 8px; }
.force-warning p:last-of-type { margin-bottom: 12px; }
.force-warning strong { color: #a07000; }
.force-form { display: inline; }

/* ---------- 11. Autocomplete ---------- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 9px;
    box-shadow: 0 10px 30px rgba(39, 44, 50, 0.12);
    max-height: 300px;
    overflow-y: auto;
    z-index: 20;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-14px) scale(0.94);
    transform-origin: top center;
    pointer-events: none;
    transition:
        opacity 220ms ease,
        transform 380ms cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0s linear 380ms;
}
.autocomplete-list.open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition:
        opacity 220ms ease,
        transform 380ms cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0s;
}
.autocomplete-item {
    padding: 10px 13px;
    cursor: pointer;
    border-bottom: 1px solid #f0f1ef;
    font-size: 13px;
    transition: background .15s;
}
.autocomplete-item:last-child { border-bottom: 0; }
.autocomplete-item:hover { background: var(--soft-orange); }
.autocomplete-item strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 2px; }
.autocomplete-item span { color: var(--muted); font-size: 11px; }

/* ---------- 12. Lista: controlli (ricerca, filtri, viste) ---------- */
.list-section { margin-top: 52px; }

.list-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    align-items: center;
}
.list-search { flex: 1 1 260px; min-width: 200px; max-width: 400px; height: 42px; font-size: 13px; }
.list-filters {
    display: flex;
    gap: 6px;
    background: var(--card);
    padding: 5px;
    border-radius: 10px;
    border: 1px solid var(--line);
}
.filter-btn {
    padding: 8px 14px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: 600 12px "DM Sans", sans-serif;
    cursor: pointer;
    border-radius: 7px;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.filter-btn:hover { background: #f5f5f3; color: var(--ink); }
.filter-btn.active { background: var(--accent); color: white; }
.list-sort {
    flex: 0 0 auto;
    width: auto;
    min-width: 170px;
    max-width: 220px;
    height: 42px;
    padding: 0 12px;
    font-size: 13px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    color: var(--ink);
}

.view-switcher {
    display: inline-flex;
    gap: 3px;
    background: var(--card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--line);
}
.view-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    border-radius: 7px;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.view-btn:hover:not(.active) { background: #f5f5f3; color: var(--ink); }
.view-btn.active { background: var(--accent); color: white; }

/* ---------- 13. Card titolo (vista schede, desktop) ---------- */
.titles-list { display: flex; flex-direction: column; gap: 12px; }

.title-item {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 18px;
    align-items: start;
    padding: 14px 18px;
    background: var(--card);
    border: 1px solid rgba(31, 37, 44, .05);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(39, 44, 50, 0.06);
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
    transition:
        transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.title-item:hover {
    transform: translate3d(0, -4px, 0);
    box-shadow: 0 16px 32px rgba(39, 44, 50, 0.13);
}
.title-item.is-to-watch {
    background: #fdfdfb;
    border-color: rgba(233, 111, 77, 0.15);
}
.title-item.is-to-watch .title-main strong {
    color: #4a4f55;
}

.title-poster {
    position: relative;
    width: 64px;
    height: 96px;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
    flex-shrink: 0;
}
.title-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }

.poster-placeholder {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    background: #f3f3f0;
    color: #c4c4bf;
    font-size: 24px;
}

.to-watch-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 3px 7px;
    background: rgba(32, 37, 44, 0.82);
    color: white;
    font: 700 9px "DM Sans", sans-serif;
    letter-spacing: .1em;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
}

.title-info { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.title-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-main strong { font-size: 15px; color: var(--ink); }
.title-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}
.meta-item { white-space: nowrap; }
.meta-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #b4b7bb;
    margin-right: 4px;
}
.title-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; flex: 0 0 auto; }
.type-pill {
    display: inline-block;
    padding: 6px 9px;
    color: var(--olive);
    background: #eff2eb;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}
.type-serie-tv { color: #80654d; background: #f7f0e7; }
.rating-badge { color: var(--accent); font-size: 15px; font-weight: 700; }
.rating-badge small { color: #a0a4a8; font-size: 10px; font-weight: 500; }
.rating-badge-empty { color: #c4c2b9; font-weight: 500; font-size: 15px; }

.title-watched {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 500;
}
.title-watched svg { color: #b8b6ad; flex-shrink: 0; }

.title-footer {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid #f0f1ef;
}

/* ---------- 14. Note personali (collassabili) ---------- */
.title-notes {
    margin-top: 8px;
    padding: 0;
    background: transparent;
    border: 0;
    display: block;
}
.note-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 6px 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    font: 500 12px "DM Sans", sans-serif;
    color: #b8b6ad;
    transition: color var(--dur-fast) ease;
}
.note-trigger:hover { color: var(--accent); }
.note-trigger .note-text {
    color: var(--muted);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    flex: 1;
}
.note-trigger .note-icon {
    flex-shrink: 0;
    color: var(--accent);
    opacity: 0.6;
    transition: opacity var(--dur-fast) ease;
}
.note-trigger:hover .note-icon { opacity: 1; }

.note-editor { margin-top: 4px; }
.notes-input {
    width: 100%;
    padding: 8px 10px;
    font: 500 13px "DM Sans", sans-serif;
    color: var(--ink);
    background: #fbfbfa;
    border: 1px solid var(--line);
    border-radius: 8px;
    resize: vertical;
    min-height: 60px;
    line-height: 1.4;
    outline: none;
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.notes-input:focus {
    background: white;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, .13);
}
.notes-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    min-height: 28px;
}
.notes-status {
    font-size: 11px;
    color: var(--olive);
    font-weight: 700;
    opacity: 0;
    transition: opacity var(--dur-fast) ease;
    margin-right: auto;
}
.notes-status.visible { opacity: 1; }
.notes-status.error { color: #c54d39; }
.notes-cancel-btn,
.notes-save-btn {
    padding: 6px 14px;
    font: 700 11px "DM Sans", sans-serif;
    border-radius: 7px;
    cursor: pointer;
    letter-spacing: .06em;
    text-transform: uppercase;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.notes-cancel-btn {
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
}
.notes-cancel-btn:hover { background: #f5f5f3; color: var(--ink); }
.notes-save-btn {
    color: white;
    background: var(--accent);
    border: 1px solid var(--accent);
}
.notes-save-btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.notes-save-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- 15. Rating widget inline (lista) ---------- */
.rating-widget { display: inline-flex; align-items: center; gap: 6px; }
.rating-view { display: inline-flex; align-items: center; gap: 4px; }
.rating-edit-btn {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 0;
    color: #c4c2b9;
    cursor: pointer;
    border-radius: 5px;
    position: relative;
    transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.rating-edit-btn::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 8px;
}
.rating-edit-btn:hover { color: var(--accent); background: var(--soft-orange); }
.rating-edit {
    display: none;
    align-items: center;
    gap: 1px;
    background: white;
    border: 1px solid var(--accent);
    border-radius: 7px;
    padding: 1px;
    box-shadow: 0 0 0 3px rgba(233, 111, 77, .13);
}
.rating-edit.is-open { display: inline-flex; }
.rating-step-btn {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--accent);
    font: 700 16px "DM Sans", sans-serif;
    cursor: pointer;
    border-radius: 5px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.rating-step-btn:hover { background: var(--soft-orange); }
.rating-step-btn:active { background: var(--accent); color: white; }
.rating-current {
    min-width: 34px;
    text-align: center;
    font: 700 13px "DM Sans", sans-serif;
    color: var(--accent);
}

/* ---------- 16. Viste alternative: griglia e compatta ---------- */
/* GRIGLIA */
.titles-list.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.titles-list.view-grid .title-item {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    gap: 0;
}
.titles-list.view-grid .title-item:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 8px 20px rgba(39, 44, 50, 0.10);
}
.titles-list.view-grid .title-poster {
    width: 100%;
    max-width: none;
    height: auto;
    aspect-ratio: 2 / 3;
    border-radius: 0;
    margin: 0;
    grid-area: unset;
}
.titles-list.view-grid .title-info {
    padding: 10px 12px 12px;
    gap: 4px;
    align-items: stretch;
    text-align: left;
    grid-area: unset;
}
.titles-list.view-grid .title-main {
    display: block;
    font-size: 13px;
    line-height: 1.25;
    min-height: 2.5em;
}
.titles-list.view-grid .title-main strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
}
.titles-list.view-grid .title-dot { display: none; }
.titles-list.view-grid .type-pill { display: none; }
.titles-list.view-grid .title-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
}
.titles-list.view-grid .meta-label { display: none; }
.titles-list.view-grid .title-notes { display: none; }
.titles-list.view-grid .title-watched { font-size: 10px; margin-top: 2px; }
.titles-list.view-grid .title-footer {
    grid-area: unset;
    margin: 0;
    padding: 8px 12px;
    border-top: 1px solid #f0f1ef;
    justify-content: flex-end;
    gap: 6px;
}
.titles-list.view-grid .icon-btn { width: 30px; height: 30px; }
/* .titles-list.view-grid .rating-edit-btn { display: none; } -- riattivata */

/* COMPATTA */
.titles-list.view-compact { gap: 6px; }
.titles-list.view-compact .title-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 8px;
}
.titles-list.view-compact .title-item:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 8px 20px rgba(39, 44, 50, 0.10);
}
.titles-list.view-compact .title-poster { display: none; }
.titles-list.view-compact .title-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
    grid-area: unset;
}
.titles-list.view-compact .title-main { flex-shrink: 0; gap: 8px; }
.titles-list.view-compact .title-main strong { font-size: 14px; }
.titles-list.view-compact .title-dot { display: none; }
.titles-list.view-compact .title-meta {
    flex: 1;
    min-width: 0;
    gap: 14px;
    margin: 0;
    font-size: 11px;
}
.titles-list.view-compact .meta-label { display: none; }
.titles-list.view-compact .title-notes { display: none; }
.titles-list.view-compact .title-watched {
    flex-shrink: 0;
    margin: 0;
    font-size: 10px;
}
.titles-list.view-compact .title-footer {
    grid-area: unset;
    margin: 0;
    padding: 0;
    border: 0;
    gap: 4px;
}
.titles-list.view-compact .icon-btn { width: 28px; height: 28px; border-radius: 6px; }
.titles-list.view-compact .icon-btn svg { width: 13px; height: 13px; }
/* .titles-list.view-compact .rating-edit-btn { display: none; } -- riattivata */

/* ---------- 17. Consigli ---------- */
.recommendations-hint {
    color: var(--muted);
    font-size: 12px;
    margin: -10px 0 18px;
    font-style: italic;
}
.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 20px;
}
.rec-card {
    background: var(--card);
    border: 1px solid rgba(31, 37, 44, .05);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(39, 44, 50, 0.06);
    display: flex;
    flex-direction: column;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
    transition:
        transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.rec-card:hover {
    transform: translate3d(0, -4px, 0);
    box-shadow: 0 18px 36px rgba(39, 44, 50, 0.15);
}
.rec-poster { width: 100%; aspect-ratio: 2 / 3; background: #f0f0ed; overflow: hidden; }
.rec-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-info { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rec-title {
    font-family: "DM Sans", sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    line-height: 1.25;
}
.rec-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
}
.rec-rating { color: var(--accent); font-weight: 700; font-size: 14px; }
.rec-rating small { color: #a0a4a8; font-size: 10px; font-weight: 500; }
.rec-genre {
    color: var(--muted);
    font-size: 11px;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rec-add-form { margin-top: auto; padding-top: 6px; }
.rec-already {
    margin: 0;
    padding: 10px 12px;
    background: #eff2eb;
    color: var(--olive);
    border-radius: 9px;
    font: 700 12px "DM Sans", sans-serif;
    text-align: center;
}

/* ---------- 18. Pannello Statistiche ---------- */
.stats-panel {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    margin-bottom: 0;
    transition:
        grid-template-rows var(--dur-slow) var(--ease-smooth),
        opacity var(--dur-base) ease,
        margin-bottom var(--dur-slow) var(--ease-smooth);
}
.stats-panel.open {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-bottom: 26px;
}
.stats-panel-inner {
    overflow: hidden;
    min-height: 0;
    padding: 26px 30px 30px;
    background: var(--card);
    border: 1px solid rgba(31, 37, 44, .05);
    border-radius: 18px;
    box-shadow: var(--shadow);
    transform: translateY(-20px) scale(0.98);
    transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}
.stats-panel.open .stats-panel-inner { transform: translateY(0) scale(1); }
.stats-title { font-family: "Playfair Display", serif; font-size: 22px; margin: 0 0 20px; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-box {
    padding: 14px 16px;
    background: #fbfbfa;
    border: 1px solid var(--line);
    border-radius: 10px;
}
.stat-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 6px;
}
.stat-value {
    font-family: "Playfair Display", serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    line-height: 1;
}
.stat-value small { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value-text { font-size: 17px; font-family: "DM Sans", sans-serif; }
.stat-extra { font-size: 11px; color: var(--muted); margin: 6px 0 0; }
.stats-extra { margin-top: 22px; }
.stats-last { margin: 6px 0 0; font-size: 14px; }
.stat-extra-inline { color: var(--muted); font-size: 12px; margin-left: 6px; }

.stat-box-highlight {
    background: #fff8e6;
    border-color: #f5d88a;
}
.stat-box-highlight .stat-label { color: #a07000; }
.stat-box-highlight .stat-value { color: #a07000; }

.top5-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin-top: 10px;
}
.top5-item { text-align: center; }
.top5-poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0ed;
    margin-bottom: 8px;
}
.top5-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.top5-info { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.top5-info strong { color: var(--ink); line-height: 1.2; }
.stats-empty { color: var(--muted); font-size: 14px; font-style: italic; margin: 0; }

/* ---------- 19. Watchlist CTA (pulsante in home) ---------- */
.watchlist-cta {
    display: flex;
    justify-content: center;
    margin-top: 28px;
}
.watchlist-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 26px;
    background: var(--card);
    color: var(--ink);
    border: 2px solid var(--accent);
    border-radius: 12px;
    font: 700 14px "DM Sans", sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        color var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.watchlist-btn:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(233, 111, 77, .25);
}
.watchlist-btn svg { flex-shrink: 0; }
.watchlist-count {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    background: var(--accent);
    color: white;
    border-radius: 13px;
    font: 700 12px "DM Sans", sans-serif;
    transition: background var(--dur-fast) ease;
}
.watchlist-btn:hover .watchlist-count {
    background: white;
    color: var(--accent);
}

/* ---------- 20. Pagine di autenticazione ---------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
}
@supports (min-height: 100dvh) {
    .auth-shell { min-height: 100dvh; }
}
.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px 34px 34px;
    background: var(--card);
    border: 1px solid rgba(31, 37, 44, .05);
    border-radius: 18px;
    box-shadow: var(--shadow);
    text-align: center;
}
.auth-title {
    font-family: "Playfair Display", serif;
    font-size: 38px;
    letter-spacing: -.04em;
    margin: 14px 0 6px;
}
.auth-title span { color: var(--accent); font-style: italic; }
.auth-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.auth-alerts { margin-bottom: 20px; }
.auth-form { display: grid; gap: 16px; text-align: left; }
.auth-button { width: 100%; height: 46px; margin-top: 6px; }
.auth-switch { margin-top: 22px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- 21. Animazioni ---------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(28px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

body.animate-enter .title-item,
body.animate-enter .rec-card,
body.animate-enter .top5-item {
    animation: fadeUp 520ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
body.animate-enter .title-item:nth-child(1),
body.animate-enter .rec-card:nth-child(1),
body.animate-enter .top5-item:nth-child(1) { animation-delay: 0ms; }
body.animate-enter .title-item:nth-child(2),
body.animate-enter .rec-card:nth-child(2),
body.animate-enter .top5-item:nth-child(2) { animation-delay: 80ms; }
body.animate-enter .title-item:nth-child(3),
body.animate-enter .rec-card:nth-child(3),
body.animate-enter .top5-item:nth-child(3) { animation-delay: 160ms; }
body.animate-enter .title-item:nth-child(4),
body.animate-enter .rec-card:nth-child(4),
body.animate-enter .top5-item:nth-child(4) { animation-delay: 240ms; }
body.animate-enter .title-item:nth-child(5),
body.animate-enter .rec-card:nth-child(5),
body.animate-enter .top5-item:nth-child(5) { animation-delay: 320ms; }
body.animate-enter .title-item:nth-child(n+6),
body.animate-enter .rec-card:nth-child(n+6) { animation-delay: 400ms; }

/* ---------- 22. Media query ---------- */

/* --- Tablet: 900px --- */
@media (max-width: 900px) {
    .title-form {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "title title"
            "state state"
            "rating add"
            "details clear";
    }
    .state-field { min-width: 0; }
}

/* --- Mobile: 700px --- */
@media (max-width: 700px) {
    input, select, textarea { font-size: 16px; }
    input, select { height: 48px; }
    .primary-button { height: 48px; font-size: 14px; }

    .page-shell { padding: 28px 18px 24px; }
    .hero { margin-bottom: 30px; }
    .form-card { padding: 22px 18px 22px; }
    .title-form {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .title-form > * { width: 100%; }
    .list-section { margin-top: 34px; }
    .list-heading { margin-bottom: 16px; }
    h2 { font-size: 24px; }
    .alerts { margin-top: -10px; }
    footer { margin-top: 36px; }

    .rating-input { height: 48px; }
    .rating-btn { width: 44px; font-size: 22px; }
    .rating-step-btn { width: 30px; height: 30px; font-size: 18px; }
    .rating-current { min-width: 40px; font-size: 14px; }

    .user-bar { margin-bottom: 18px; font-size: 12px; flex-wrap: wrap; }
    .logout-btn { padding: 8px 14px; }
    .stats-toggle { padding: 8px 12px; font-size: 10px; }

    .autocomplete-item { padding: 12px 14px; font-size: 14px; }
    .autocomplete-item strong { font-size: 14px; }

    .auth-card { padding: 34px 22px 28px; }
    .auth-title { font-size: 32px; }

    .title-item {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-areas:
            "poster"
            "info"
            "footer";
        padding: 18px 16px;
        gap: 14px;
    }
    .title-poster {
        grid-area: poster;
        width: 100%;
        height: auto;
        aspect-ratio: 2 / 3;
        max-width: 200px;
        margin: 0 auto;
        border-radius: 12px;
    }
    .title-info {
        grid-area: info;
        align-items: center;
        text-align: center;
    }
    .title-main { justify-content: center; }
    .title-meta { justify-content: center; gap: 14px; }
    .title-notes { text-align: left; width: 100%; }
    .title-footer {
        grid-area: footer;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    .icon-btn { width: 42px; height: 42px; }
    .icon-btn svg { width: 17px; height: 17px; }

    .watched-btn { width: 100%; max-width: 260px; height: 42px; font-size: 13px; }

    .list-controls { flex-direction: column; align-items: stretch; }
    .list-filters { justify-content: center; width: 100%; }
    .list-search, .list-sort { width: 100%; }
    input.list-search { font-size: 16px; }
    .view-switcher { width: 100%; justify-content: center; }

    .list-heading {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .list-heading-actions { justify-content: flex-start; }

    .form-buttons {
        flex-direction: column-reverse;
        gap: 10px;
    }
    .form-buttons > * { width: 100%; height: 48px; }

    .back-to-list-wrap { margin-top: 32px; }
    .back-to-list { width: 100%; max-width: 320px; justify-content: center; }

    .recommendations-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .rec-info { padding: 12px 12px 14px; }
    .rec-title { font-size: 13px; }
    .rec-add-btn { font-size: 11px; padding: 9px 8px; }

    .stats-panel-inner { padding: 20px 18px 22px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 22px; }
    .stat-value-text { font-size: 15px; }
    .top5-grid { grid-template-columns: repeat(3, 1fr); }

    .watchlist-cta { margin-top: 22px; }
    .watchlist-btn { width: 100%; justify-content: center; }

    .titles-list.view-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .titles-list.view-grid .title-footer { padding: 6px 8px; }
    .titles-list.view-grid .icon-btn { width: 28px; height: 28px; }
    .titles-list.view-grid .icon-btn svg { width: 13px; height: 13px; }

    .titles-list.view-compact .title-item { padding: 8px 10px; gap: 8px; }
    .titles-list.view-compact .title-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .titles-list.view-compact .title-meta { gap: 8px; }
    .titles-list.view-compact .title-watched { display: none; }
}

/* --- Mobile piccolo: 380px --- */
    .title-form { grid-template-columns: 1fr 1fr; gap: 14px 10px; }
    .field-title { grid-column: 1 / -1; }
    .primary-button { grid-column: 1 / -1; }

/* --- Desktop: layout card 2 colonne (poster+footer | info) --- */
@media (min-width: 701px) {
    .title-item {
        grid-template-columns: 168px 1fr;
        grid-template-areas:
            "poster info"
            "footer info";
        column-gap: 20px;
        row-gap: 10px;
        align-items: start;
        padding: 14px 18px;
    }
    .title-poster {
        grid-area: poster;
        width: 110px;
        height: auto;
        aspect-ratio: 2 / 3;
        border-radius: 10px;
        margin: 0 auto;
    }
    .title-info { grid-area: info; }
    .title-footer {
        grid-area: footer;
        display: flex;
        justify-content: center;
        gap: 8px;
        padding-top: 0;
        margin-top: 0;
        border-top: 0;
    }
}

/* ---------- 23. Accessibilità: riduci movimento ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .title-item,
    .rec-card {
        will-change: auto;
        transition: none;
    }
    .title-item:hover,
    .rec-card:hover {
        transform: none;
    }
}
/* ============================================================
   v17 — Campo Rewatch (stepper) nella pagina di modifica
   ============================================================ */
.rewatch-field input {
    font-size: 14px;
}
/* ============================================================
   v18 — Dark mode
   ============================================================ */

/* --- User bar: layout con Stats a sinistra --- */
.user-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============================================================
   Palette scura: ridefinisce tutte le variabili
   ============================================================ */
[data-theme="dark"] {
    --ink: #e8eaed;
    --muted: #9aa1ac;
    --paper: #15171a;
    --card: #1f2328;
    --line: #2e333a;
    --accent: #ff8465;
    --accent-dark: #e96f4d;
    --olive: #a3b18c;
    --soft-orange: #3a2820;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* --- Base --- */
[data-theme="dark"] body {
    background: var(--paper);
}

/* --- Card generiche --- */
[data-theme="dark"] .card,
[data-theme="dark"] .empty-state {
    background: var(--card);
    border-color: rgba(255, 255, 255, 0.05);
}

/* --- Input e select --- */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #262a30;
    color: var(--ink);
    border-color: var(--line);
}
[data-theme="dark"] input::placeholder { color: #6a7079; }
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    background: #262a30;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 132, 101, 0.20);
}

/* --- Rating input (stepper del voto) --- */
[data-theme="dark"] .rating-input {
    background: #262a30;
    border-color: var(--line);
}
[data-theme="dark"] .rating-input:focus-within {
    background: #262a30;
    border-color: var(--accent);
}
[data-theme="dark"] .rating-btn:hover { background: rgba(255, 132, 101, 0.15); }

/* --- Card titolo --- */
[data-theme="dark"] .title-item {
    background: var(--card);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .title-item:hover {
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .title-item.is-to-watch {
    background: #1d2024;
    border-color: rgba(255, 132, 101, 0.25);
}
[data-theme="dark"] .title-item.is-to-watch .title-main strong { color: var(--ink); }
[data-theme="dark"] .title-footer { border-top-color: rgba(255, 255, 255, 0.06); }

/* --- Icon buttons (matita, lampadina, cestino) --- */
[data-theme="dark"] .icon-btn {
    border-color: var(--line);
    color: #7a808a;
}
[data-theme="dark"] .icon-btn-edit {
    color: var(--accent);
    border-color: rgba(255, 132, 101, 0.35);
}
[data-theme="dark"] .icon-btn-edit:hover {
    background: rgba(255, 132, 101, 0.12);
    border-color: var(--accent);
}
[data-theme="dark"] .icon-btn-recommend {
    color: #e0b95a;
    border-color: rgba(224, 185, 90, 0.35);
}
[data-theme="dark"] .icon-btn-recommend:hover {
    background: rgba(224, 185, 90, 0.12);
    border-color: #e0b95a;
}
[data-theme="dark"] .icon-btn-delete {
    color: #e07a68;
    border-color: rgba(224, 122, 104, 0.35);
}
[data-theme="dark"] .icon-btn-delete:hover {
    background: rgba(224, 122, 104, 0.12);
    border-color: #e07a68;
}
[data-theme="dark"] .icon-btn-watched {
    color: var(--olive);
    border-color: rgba(163, 177, 140, 0.35);
}
[data-theme="dark"] .icon-btn-watched:hover {
    background: rgba(163, 177, 140, 0.12);
    border-color: var(--olive);
}

/* --- Poster placeholder --- */
[data-theme="dark"] .poster-placeholder {
    background: #262a30;
    color: #4a4f56;
}

/* --- Type pill / meta --- */
[data-theme="dark"] .type-pill {
    background: #2a2e35;
    color: #a3b18c;
}
[data-theme="dark"] .type-serie-tv {
    background: #2e2620;
    color: #c4a882;
}

/* --- List controls: filtri, search, sort, view switcher --- */
[data-theme="dark"] .list-filters,
[data-theme="dark"] .view-switcher {
    background: var(--card);
    border-color: var(--line);
}
[data-theme="dark"] .filter-btn:hover,
[data-theme="dark"] .view-btn:hover:not(.active) {
    background: #262a30;
    color: var(--ink);
}
[data-theme="dark"] .list-sort {
    background: var(--card);
    border-color: var(--line);
    color: var(--ink);
}
[data-theme="dark"] input.list-search {
    background: #262a30;
    border-color: var(--line);
    color: var(--ink);
}

/* --- Statistiche --- */
[data-theme="dark"] .stats-panel-inner {
    background: var(--card);
    border-color: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .stat-box {
    background: #262a30;
    border-color: var(--line);
}
[data-theme="dark"] .stat-box-highlight {
    background: #3a2e1a;
    border-color: #6b5528;
}
[data-theme="dark"] .stat-box-highlight .stat-label { color: #e0b95a; }
[data-theme="dark"] .stat-box-highlight .stat-value { color: #e0b95a; }
[data-theme="dark"] .top5-poster { background: #262a30; }

/* --- Autocomplete --- */
[data-theme="dark"] .autocomplete-list {
    background: var(--card);
    border-color: var(--line);
}
[data-theme="dark"] .autocomplete-item {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .autocomplete-item:hover {
    background: #262a30;
}

/* --- Watchlist badge --- */
[data-theme="dark"] .to-watch-badge {
    background: rgba(255, 132, 101, 0.9);
    color: #1a1a1a;
}

/* --- Consigli --- */
[data-theme="dark"] .rec-card {
    background: var(--card);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .rec-card:hover {
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .rec-poster { background: #262a30; }
[data-theme="dark"] .rec-already {
    background: #2a2e35;
    color: var(--olive);
}

/* --- Pulsanti azione --- */
[data-theme="dark"] .logout-btn {
    background: var(--soft-orange);
    color: var(--accent);
}
[data-theme="dark"] .logout-btn:hover {
    background: var(--accent);
    color: #1a1a1a;
}
[data-theme="dark"] .cancel-button {
    color: var(--muted);
    border-color: var(--line);
}
[data-theme="dark"] .cancel-button:hover {
    background: #262a30;
    color: var(--ink);
    border-color: #3a3f46;
}

/* --- Watchlist CTA --- */
[data-theme="dark"] .watchlist-btn {
    background: var(--card);
    color: var(--ink);
    border-color: var(--accent);
}
[data-theme="dark"] .watchlist-btn:hover {
    background: var(--accent);
    color: #1a1a1a;
}
[data-theme="dark"] .watchlist-btn:hover .watchlist-count {
    background: #1a1a1a;
    color: var(--accent);
}

/* --- Note (pagina di modifica, lasciamo attivo per non rompere nulla) --- */
[data-theme="dark"] .note-editor textarea,
[data-theme="dark"] .field-notes textarea {
    background: #262a30;
    color: var(--ink);
    border-color: var(--line);
}
[data-theme="dark"] .note-editor textarea:focus,
[data-theme="dark"] .field-notes textarea:focus {
    background: #262a30;
    border-color: var(--accent);
}

/* --- Rating edit inline --- */
[data-theme="dark"] .rating-edit {
    background: var(--card);
    border-color: var(--accent);
}

/* --- Alerts --- */
[data-theme="dark"] .alert-success {
    background: #1f3226;
    color: #7fc297;
}
[data-theme="dark"] .alert-error {
    background: #3a1e18;
    color: #e8a08e;
}

/* --- Force warning (titolo non trovato) --- */
[data-theme="dark"] .force-warning {
    background: #3a2e1a;
    border-color: #6b5528;
    color: #e0b95a;
}
[data-theme="dark"] .force-warning strong { color: #f0c468; }

/* --- Auth (login/register) --- */
[data-theme="dark"] .auth-card {
    background: var(--card);
    border-color: rgba(255, 255, 255, 0.05);
}
/* ============================================================
   v18b — Fix riga separatrice in dark mode
   ============================================================ */

[data-theme="dark"] .title-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}
/* ============================================================
   v19 — Fix pulsanti mobile (in riga, compatti)
   ============================================================ */
@media (max-width: 700px) {
    /* Card view: 3 pulsanti in riga */
    .title-footer .icon-btn {
        width: 42px;
        height: 42px;
    }

    /* Grid view: 3 pulsanti in riga, più compatti */
    .titles-list.view-grid .title-footer {
        justify-content: center;
        gap: 6px;
        padding: 8px;
    }
    .titles-list.view-grid .icon-btn {
        width: 34px;
        height: 34px;
    }
    .titles-list.view-grid .icon-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Compatta: pulsanti in riga, allineati a destra */
    .titles-list.view-compact .title-footer {
        flex-direction: row;
    }
}
/* ============================================================
   v20 — Autocomplete: stile "Già in lista"
   ============================================================ */
.autocomplete-item.already-in-list {
    display: block;
    text-decoration: none;
    color: inherit;
    background: transparent;
    opacity: 0.75;
    cursor: pointer;
}
.autocomplete-item.already-in-list strong {
    color: var(--muted);
}
.autocomplete-item.already-in-list:hover {
    background: #f5f5f2;
    opacity: 1;
}
.already-label {
    display: inline-block;
    margin-top: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--olive);
    background: #eff2eb;
    padding: 2px 7px;
    border-radius: 4px;
}
[data-theme="dark"] .autocomplete-item.already-in-list:hover {
    background: #262a30;
}
[data-theme="dark"] .already-label {
    background: #2a2e35;
    color: #a3b18c;
}
/* ============================================================
   v21 — Form Aggiungi collassabile + pulsante Torna su
   ============================================================ */

/* --- CTA "Aggiungi un titolo" --- */
.add-cta {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}
.add-cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 480px;
    padding: 16px 28px;
    background: var(--card);
    color: var(--ink);
    border: 2px dashed var(--line);
    border-radius: 14px;
    font: 700 14px "DM Sans", sans-serif;
    cursor: pointer;
    transition:
        border-color var(--dur-fast) ease,
        color var(--dur-fast) ease,
        background var(--dur-fast) ease,
        transform var(--dur-base) var(--ease-smooth);
}
.add-cta-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--soft-orange);
    transform: translateY(-1px);
}
.add-cta-btn span {
    font-size: 22px;
    font-weight: 400;
    line-height: 0;
    color: var(--accent);
    margin-top: -2px;
}

/* --- Pannello form collassabile --- */
.add-panel {
    display: none;
}
.add-panel.open {
    display: block;
    animation: fadeUp 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* --- Pulsante × per chiudere --- */
.add-close-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    font-family: inherit;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.add-close-btn:hover {
    background: var(--soft-orange);
    color: var(--accent);
}

/* --- Pulsante "Torna su" --- */
.scroll-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(233, 111, 77, 0.35);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition:
        opacity 300ms ease,
        transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
        background 200ms ease;
    z-index: 50;
}
.scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.scroll-top-btn:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
}

/* --- Dark --- */
[data-theme="dark"] .add-cta-btn:hover {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: var(--accent);
}
[data-theme="dark"] .add-close-btn:hover {
    background: var(--soft-orange);
    color: var(--accent);
}

/* --- Mobile --- */
@media (max-width: 700px) {
    .add-cta {
        margin-bottom: 22px;
    }
    .add-cta-btn {
        padding: 14px 20px;
        font-size: 13px;
    }
    .scroll-top-btn {
        bottom: 18px;
        right: 18px;
        width: 42px;
        height: 42px;
    }
}
/* ============================================================
   v22 — Pulsante "Svuota" nel form di aggiunta
   ============================================================ */
.clear-form-btn {
    height: 46px;
    padding: 0 18px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 9px;
    font: 700 13px "DM Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background var(--dur-fast) ease,
        color var(--dur-fast) ease,
        border-color var(--dur-fast) ease;
}
.clear-form-btn:hover {
    background: #f5f5f3;
    color: var(--ink);
    border-color: #d5d5d0;
}
[data-theme="dark"] .clear-form-btn:hover {
    background: #262a30;
    color: var(--ink);
    border-color: #3a3f46;
}

@media (max-width: 700px) {
    .clear-form-btn {
        width: 100%;
    }
}
/* ============================================================
   v23 — Modale di conferma eliminazione
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    background: rgba(20, 22, 26, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 250ms ease;
    padding: 20px;
}
.modal-overlay.open {
    opacity: 1;
}
.modal-box {
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
    padding: 28px 26px 22px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    transform: scale(0.94);
    transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-overlay.open .modal-box {
    transform: scale(1);
}
.modal-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 16px;
    background: #ffede8;
    color: #c54d39;
    border-radius: 50%;
}
.modal-title {
    font-family: "DM Sans", sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 8px;
}
.modal-text {
    font-size: 14px;
    color: var(--muted);
    margin: 0 0 4px;
    line-height: 1.4;
}
.modal-text strong {
    color: var(--ink);
}
.modal-warning {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 22px;
    font-style: italic;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.modal-cancel-btn,
.modal-confirm-btn {
    flex: 1;
    height: 42px;
    border: 0;
    border-radius: 10px;
    font: 700 13px "DM Sans", sans-serif;
    cursor: pointer;
    transition: background 200ms ease, transform 200ms ease;
}
.modal-cancel-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
}
.modal-cancel-btn:hover {
    background: #f5f5f3;
    color: var(--ink);
}
.modal-confirm-btn {
    background: #c54d39;
    color: white;
    box-shadow: 0 4px 12px rgba(197, 77, 57, 0.30);
}
.modal-confirm-btn:hover {
    background: #a02c20;
    transform: translateY(-1px);
}
.modal-confirm-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}
[data-theme="dark"] .modal-box {
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .modal-icon {
    background: #3a1e18;
    color: #e8a08e;
}
[data-theme="dark"] .modal-cancel-btn:hover {
    background: #262a30;
    color: var(--ink);
}
/* Fix: la modale nascosta deve davvero essere display: none */
.modal-overlay[hidden] {
    display: none !important;
}
/* ============================================================
   v24 — Login: pulsante secondario + "Password dimenticata?"
   ============================================================ */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .12em;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}
.auth-divider span {
    flex-shrink: 0;
}

.auth-secondary-button {
    display: block;
    width: 100%;
    padding: 13px 18px;
    color: var(--accent);
    background: transparent;
    border: 2px solid var(--accent);
    border-radius: 10px;
    font: 700 13px "DM Sans", sans-serif;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition:
        background var(--dur-fast) ease,
        color var(--dur-fast) ease,
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.auth-secondary-button:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 7px 15px rgba(233, 111, 77, .22);
}

.auth-help {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    text-align: left;
}
.auth-help summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 0;
    list-style: none;
    position: relative;
    transition: color var(--dur-fast) ease;
}
.auth-help summary::-webkit-details-marker { display: none; }
.auth-help summary::before {
    content: '?';
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-right: 8px;
    background: var(--soft-orange);
    color: var(--accent);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
}
.auth-help summary:hover { color: var(--accent); }

.auth-help-content {
    margin-top: 14px;
    padding: 14px 16px;
    background: var(--soft-orange);
    border-left: 3px solid var(--accent);
    border-radius: 0 10px 10px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #6b4e00;
}
.auth-help-content p {
    margin: 0 0 8px;
}
.auth-help-content p:last-child {
    margin-bottom: 0;
}
.auth-help-email a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
    word-break: break-all;
}
.auth-help-email a:hover {
    text-decoration: underline;
}
.auth-help-note {
    font-size: 12px;
    font-style: italic;
    opacity: 0.8;
}

/* Dark */
[data-theme="dark"] .auth-help-content {
    color: #e0b95a;
    background: #3a2e1a;
    border-left-color: #e0b95a;
}
[data-theme="dark"] .auth-help-email a {
    color: #f0c468;
}
/* ============================================================
   v25 — Pagina di dettaglio titolo
   ============================================================ */

/* --- HERO con backdrop --- */
.detail-hero {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    margin-bottom: 40px;
    background: var(--card);
    box-shadow: var(--shadow);
}
.detail-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
    filter: brightness(0.55) saturate(1.1);
    z-index: 0;
}
.detail-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.2) 0%,
        rgba(0, 0, 0, 0.75) 100%
    );
}
.detail-hero-content {
    position: relative;
    z-index: 1;
    padding: 60px 40px 40px;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 32px;
    align-items: end;
    color: white;
}
.detail-poster {
    width: 220px;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    background: #1a1d22;
}
.detail-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.detail-poster .poster-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: #2a2e35;
    color: #6a7079;
    font-size: 60px;
}

.detail-info { min-width: 0; color: white; }
.detail-info .section-label { color: var(--accent); }
.detail-title {
    font-family: "Playfair Display", serif;
    font-size: clamp(32px, 4.5vw, 52px);
    line-height: 1.05;
    letter-spacing: -.03em;
    margin: 0 0 12px;
    color: white;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}
.detail-original {
    font-size: 14px;
    opacity: 0.75;
    margin: 0 0 18px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    font-size: 13px;
    margin-bottom: 18px;
    opacity: 0.95;
}
.detail-meta strong {
    font-weight: 700;
    font-size: 9px;
    letter-spacing: .12em;
    text-transform: uppercase;
    opacity: 0.6;
    display: inline-block;
    margin-right: 4px;
    vertical-align: 1px;
}
.detail-rating {
    color: var(--accent);
    font-weight: 700;
    font-size: 15px;
}
.detail-rating small {
    font-size: 11px;
    opacity: 0.7;
    font-weight: 500;
}
.detail-votes { font-size: 12px; opacity: 0.7; }

.detail-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.detail-genres .type-pill {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.detail-director,
.detail-country {
    font-size: 13px;
    margin: 0 0 6px;
    opacity: 0.9;
}
.detail-director strong,
.detail-country strong { color: white; }

.detail-actions {
    margin-top: 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.detail-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border: 0;
    border-radius: 11px;
    font: 700 14px "DM Sans", sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition:
        background var(--dur-fast) ease,
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.detail-cta-edit {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.detail-cta-edit:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}
.detail-cta-add {
    background: var(--accent);
    color: white;
    box-shadow: 0 8px 20px rgba(233, 111, 77, 0.4);
}
.detail-cta-add:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(233, 111, 77, 0.5);
}

/* --- SEZIONI --- */
.detail-section {
    margin-bottom: 40px;
}
.detail-section-title {
    font-family: "Playfair Display", serif;
    font-size: 24px;
    margin: 0 0 16px;
    color: var(--ink);
}
.detail-overview {
    font-size: 15px;
    line-height: 1.65;
    color: var(--ink);
    margin: 0;
}
.detail-overview-empty {
    color: var(--muted);
    font-style: italic;
}

/* --- TRAILER --- */
.detail-trailer {
    position: relative;
    width: 100%;
    max-width: 860px;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: #000;
}
.detail-trailer iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- CAST --- */
.detail-cast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}
.cast-card {
    background: var(--card);
    border: 1px solid rgba(31, 37, 44, 0.05);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(39, 44, 50, 0.06);
    text-align: center;
    transition: transform var(--dur-base) var(--ease-smooth), box-shadow var(--dur-base) var(--ease-smooth);
}
.cast-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(39, 44, 50, 0.12);
}
.cast-photo {
    width: 100%;
    aspect-ratio: 2 / 3;
    background: #f0f0ed;
    overflow: hidden;
}
.cast-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cast-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: #e8e9e6;
    color: #b4b7bb;
    font-size: 42px;
}
.cast-info {
    padding: 10px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.cast-info strong {
    font-size: 13px;
    color: var(--ink);
    line-height: 1.2;
}
.cast-info span {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.2;
}

/* --- Dark mode --- */
[data-theme="dark"] .cast-card {
    border-color: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .cast-photo { background: #262a30; }
[data-theme="dark"] .cast-placeholder {
    background: #262a30;
    color: #4a4f56;
}

/* --- Mobile --- */
@media (max-width: 700px) {
    .detail-hero-content {
        grid-template-columns: 1fr;
        padding: 40px 22px 28px;
        gap: 20px;
        text-align: center;
    }
    .detail-poster {
        width: 180px;
        margin: 0 auto;
    }
    .detail-info { text-align: center; }
    .detail-meta { justify-content: center; }
    .detail-genres { justify-content: center; }
    .detail-cta { width: 100%; justify-content: center; }

    .detail-section-title { font-size: 20px; }
    .detail-trailer { border-radius: 10px; }

    .detail-cast-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }
    .cast-info { padding: 8px 6px 10px; }
    .cast-info strong { font-size: 11px; }
    .cast-info span { font-size: 10px; }
}
/* ============================================================
   v26 — Card cliccabile (poster + titolo + meta)
   ============================================================ */

/* La card diventa un contesto di posizionamento */
.title-item,
.rec-card {
    position: relative;
}

/* Link del titolo: esteso a tutta la card */
.title-link {
    color: inherit;
    text-decoration: none;
}
.title-link strong {
    transition: color var(--dur-fast) ease;
}
.title-link:hover strong {
    color: var(--accent);
}
.title-link::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: pointer;
}

/* Esclusioni: pulsanti, steeper, note restano SOPRA l'overlay */
.title-footer,
.rating-widget,
.title-notes,
.title-actions-inline {
    position: relative;
    z-index: 2;
}

/* Consigli: link esteso sulla card */
.rec-title-link {
    color: inherit;
    text-decoration: none;
    transition: color var(--dur-fast) ease;
}
.rec-title-link:hover {
    color: var(--accent);
}
.rec-title-link::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: pointer;
}
.rec-add-form,
.rec-add-btn,
.rec-already {
    position: relative;
    z-index: 2;
    margin-top: auto;
}
/* ============================================================
   v27 — Stepper voto: pulsanti Salva / Annulla
   ============================================================ */
.rating-save-btn,
.rating-cancel-btn {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 3px;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.rating-save-btn {
    background: var(--accent);
    color: white;
}
.rating-save-btn:hover {
    background: var(--accent-dark);
}
.rating-cancel-btn {
    background: transparent;
    color: var(--muted);
}
.rating-cancel-btn:hover {
    background: #f5f5f3;
    color: var(--ink);
}
[data-theme="dark"] .rating-cancel-btn:hover {
    background: #2a2e35;
    color: var(--ink);
}

/* Nel rating-edit, separa visivamente i 2 nuovi pulsanti */
.rating-edit {
    padding: 2px;
    gap: 2px;
}
.rating-save-btn,
.rating-cancel-btn {
    margin-left: 2px;
}

/* --- Mobile: pulsanti più grandi per il tocco --- */
@media (max-width: 700px) {
    .rating-save-btn,
    .rating-cancel-btn {
        width: 32px;
        height: 32px;
    }
    .rating-save-btn svg,
    .rating-cancel-btn svg {
        width: 15px;
        height: 15px;
    }
}
/* ============================================================
   v28 — Fix stepper voto in vista griglia (mobile)
   ============================================================ */
@media (max-width: 700px) {
    /* Il widget voto occupa tutta la larghezza della colonna */
    .titles-list.view-grid .rating-widget {
        width: 100%;
        display: block;
    }

    /* Lo stepper aperto usa tutta la larghezza, distribuisce i pulsanti */
    .titles-list.view-grid .rating-edit.is-open {
        display: flex;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        justify-content: space-between;
        align-items: center;
        padding: 2px 3px;
        gap: 2px;
    }

    /* Pulsanti più compatti ma ancora toccabili */
    .titles-list.view-grid .rating-edit .rating-step-btn {
        width: 26px;
        height: 26px;
        font-size: 15px;
        flex-shrink: 0;
    }
    .titles-list.view-grid .rating-edit .rating-current {
        min-width: 28px;
        font-size: 12px;
        text-align: center;
        flex-shrink: 0;
    }
    .titles-list.view-grid .rating-edit .rating-save-btn,
    .titles-list.view-grid .rating-edit .rating-cancel-btn {
        width: 26px;
        height: 26px;
        flex-shrink: 0;
        margin-left: 0;
    }
    .titles-list.view-grid .rating-edit .rating-save-btn svg,
    .titles-list.view-grid .rating-edit .rating-cancel-btn svg {
        width: 12px;
        height: 12px;
    }
}
/* ============================================================
   v29 — User-bar: pulsanti a sinistra di default, ma nella home
   con user-info vanno separati (Stats a sinistra, Ciao/Esci a destra)
   ============================================================ */
.user-bar {
    justify-content: flex-start;
    gap: 12px;
}
.user-bar:has(.user-info) {
    justify-content: space-between;
}
/* ============================================================
   v30 — Filtri avanzati
   ============================================================ */

/* --- Pulsante "Filtri" --- */
.filters-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 42px;
    padding: 0 14px;
    background: var(--card);
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 10px;
    font: 600 12px "DM Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition:
        background var(--dur-fast) ease,
        color var(--dur-fast) ease,
        border-color var(--dur-fast) ease;
}
.filters-toggle:hover {
    background: #f5f5f3;
    color: var(--ink);
}
.filters-toggle.active {
    color: var(--accent);
    border-color: #f0c4b6;
    background: var(--soft-orange);
}
.filters-toggle svg { flex-shrink: 0; }
.filters-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    font: 700 10px "DM Sans", sans-serif;
    margin-left: 2px;
}

/* --- Pannello filtri (collassabile) --- */
.filters-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 22px;
    align-items: end;
    width: 100%;
    box-sizing: border-box;
    padding: 18px 22px 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(39, 44, 50, 0.05);
    margin-bottom: 18px;
    opacity: 0;
    transform: translateY(-8px);
    transition:
        opacity 250ms ease,
        transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
}
.filters-panel.open {
    opacity: 1;
    transform: translateY(0);
    position: relative;
    z-index: 100;
}
.filter-field {
    flex: 1 1 200px;
    min-width: 180px;
}
.filter-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}
.filter-field select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    background: #fbfbfa;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 9px;
    font: 500 13px "DM Sans", sans-serif;
    cursor: pointer;
    outline: none;
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.filter-field select:focus {
    background: white;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, .13);
}

/* --- Checkbox come pill-toggle --- */
.filter-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: 600 12px "DM Sans", sans-serif;
    letter-spacing: .02em;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition:
        background .15s ease,
        border-color .15s ease,
        color .15s ease;
}
.filter-check:hover {
    border-color: rgba(233, 111, 77, 0.45);
    color: var(--ink);
}
.filter-check:has(input[type="checkbox"]:checked) {
    background: rgba(233, 111, 77, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}
.filter-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    margin: 0;
    cursor: pointer;
}
[data-theme="dark"] .filter-check:hover {
    color: var(--ink);
}
[data-theme="dark"] .filter-check:has(input[type="checkbox"]:checked) {
    background: rgba(255, 122, 89, 0.14);
    border-color: var(--accent);
    color: #ff9478;
}

/* --- Pulsante azzera --- */
.filters-reset {
    flex: 0 0 auto;
    align-self: end;
    height: 42px;
    padding: 0 18px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 9px;
    font: 700 12px "DM Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.filters-reset:hover {
    background: #f5f5f3;
    color: var(--ink);
    border-color: #d5d5d0;
}

/* --- Dark --- */
[data-theme="dark"] .filters-toggle:hover,
[data-theme="dark"] .filters-reset:hover {
    background: #262a30;
    color: var(--ink);
}
[data-theme="dark"] .filters-toggle.active {
    background: var(--soft-orange);
    color: var(--accent);
}
[data-theme="dark"] .filter-field select {
    background: #262a30;
    color: var(--ink);
}
[data-theme="dark"] .filter-field select:focus {
    background: #262a30;
}

/* --- Mobile --- */
@media (max-width: 700px) {
    .filters-toggle {
        width: 100%;
        justify-content: center;
    }
    .filters-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px 18px 18px;
    }
    .filter-checks {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }
    .filters-reset {
        width: 100%;
    }
}
/* Fix: elementi con [hidden] devono essere davvero nascosti */
.filters-panel[hidden],
.filters-badge[hidden] {
    display: none !important;
}
/* ============================================================
   v31 — Vista Saghe
   ============================================================ */

.titles-list.view-sagas {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* --- Gruppo saga --- */
.saga-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.saga-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}
.saga-header h3 {
    font-family: "Playfair Display", serif;
    font-size: 22px;
    letter-spacing: -.02em;
    margin: 0;
    color: var(--ink);
}
.saga-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--soft-orange);
    color: var(--accent);
    border-radius: 8px;
    font: 700 11px "DM Sans", sans-serif;
    letter-spacing: .04em;
}
.saga-group-others .saga-badge { display: none; }

/* --- Griglia interna della saga --- */
.saga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

/* --- Card compatta in vista saghe --- */
.titles-list.view-sagas .title-item {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    gap: 0;
    background: var(--card);
    border: 1px solid rgba(31, 37, 44, 0.05);
    box-shadow: 0 4px 14px rgba(39, 44, 50, 0.06);
    transform: translate3d(0, 0, 0);
    transition:
        transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.titles-list.view-sagas .title-item:hover {
    transform: translate3d(0, -3px, 0);
    box-shadow: 0 12px 28px rgba(39, 44, 50, 0.14);
}
.titles-list.view-sagas .title-poster {
    width: 100%;
    max-width: none;
    height: auto;
    aspect-ratio: 2 / 3;
    border-radius: 0;
    margin: 0;
    grid-area: unset;
}
.titles-list.view-sagas .title-info {
    padding: 10px 12px 12px;
    gap: 4px;
    align-items: stretch;
    text-align: left;
    grid-area: unset;
}
.titles-list.view-sagas .title-main {
    display: block;
    font-size: 13px;
    line-height: 1.25;
    min-height: 2.5em;
}
.titles-list.view-sagas .title-main strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
}
.titles-list.view-sagas .title-dot { display: none; }
.titles-list.view-sagas .type-pill { display: none; }
.titles-list.view-sagas .title-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
}
.titles-list.view-sagas .meta-label { display: none; }

/* Nascondi tutto ciò che non serve in vista saghe */
.titles-list.view-sagas .title-footer,
.titles-list.view-sagas .rating-widget,
.titles-list.view-sagas .rating-edit-btn,
.titles-list.view-sagas .title-watched,
.titles-list.view-sagas .title-rewatch {
    display: none !important;
}

/* --- Dark --- */
[data-theme="dark"] .titles-list.view-sagas .title-item {
    border-color: rgba(255, 255, 255, 0.05);
}

/* --- Mobile --- */
@media (max-width: 700px) {
    .titles-list.view-sagas { gap: 28px; }
    .saga-header h3 { font-size: 18px; }
    .saga-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .saga-badge { font-size: 10px; padding: 3px 8px; }
}
/* ============================================================
   v32 — Link "Dettagli" nell'autocomplete
   ============================================================ */
.autocomplete-details-link {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--soft-orange);
    border-radius: 5px;
    text-decoration: none;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.autocomplete-details-link:hover {
    background: var(--accent);
    color: white;
}
[data-theme="dark"] .autocomplete-details-link {
    background: #3a2820;
    color: var(--accent);
}
[data-theme="dark"] .autocomplete-details-link:hover {
    background: var(--accent);
    color: #15171a;
}
/* ============================================================
   v33 — Pagina dettaglio: due pulsanti di aggiunta
   ============================================================ */
.detail-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.detail-cta-watch {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.detail-cta-watch:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

@media (max-width: 700px) {
    .detail-add-form {
        flex-direction: column;
        width: 100%;
    }
    .detail-add-form .detail-cta {
        width: 100%;
        justify-content: center;
    }
}
/* ============================================================
   v34 — Pulsante "Dettagli" nel form di aggiunta
   ============================================================ */
.details-form-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 46px;
    padding: 0 16px;
    background: transparent;
    color: var(--accent);
    border: 1px solid #f0c4b6;
    border-radius: 9px;
    font: 700 13px "DM Sans", sans-serif;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background var(--dur-fast) ease,
        color var(--dur-fast) ease,
        border-color var(--dur-fast) ease;
}
.details-form-btn:hover {
    background: var(--soft-orange);
    color: var(--accent-dark);
    border-color: var(--accent);
}
.details-form-btn svg { flex-shrink: 0; }
.details-form-btn[hidden] { display: none; }

[data-theme="dark"] .details-form-btn:hover {
    background: var(--soft-orange);
    color: var(--accent);
}

@media (max-width: 700px) {
    .details-form-btn {
        width: 100%;
        justify-content: center;
    }
}
/* ============================================================
   v35 — Fix: reset esplicito di grid-template-* nelle viste alternative
   ============================================================ */

@media (min-width: 701px) {
    .titles-list.view-grid .title-item,
    .titles-list.view-compact .title-item,
    .titles-list.view-sagas .title-item {
        grid-template-columns: none;
        grid-template-areas: none;
    }
}

/* Assicurati che le regole della vista griglia siano SEMPRE applicate */
.titles-list.view-grid .title-poster {
    grid-area: unset;
}
.titles-list.view-grid .title-info {
    grid-area: unset;
}
.titles-list.view-grid .title-footer {
    grid-area: unset;
}

.titles-list.view-compact .title-poster {
    grid-area: unset;
}
.titles-list.view-compact .title-info {
    grid-area: unset;
}
.titles-list.view-compact .title-footer {
    grid-area: unset;
}
/* ============================================================
   v36 — Stato (visti / da vedere) come pill cliccabili
   ============================================================ */
.state-pills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    height: 46px;
}
.state-pill {
    position: relative;
    display: block;
    cursor: pointer;
}
.state-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.state-pill > span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 100%;
    padding: 0 6px;
    background: #fbfbfa;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 9px;
    font: 700 11px "DM Sans", sans-serif;
    white-space: nowrap;
    transition:
        background var(--dur-fast) ease,
        color var(--dur-fast) ease,
        border-color var(--dur-fast) ease,
        transform var(--dur-fast) ease;
}
.state-pill:hover > span {
    border-color: #c9cbc7;
    background: #f5f5f2;
}
.state-pill input[type="radio"]:checked + span {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 10px rgba(233, 111, 77, 0.25);
}
.state-pill-watch input[type="radio"]:checked + span {
    background: #107bde;
    border-color: #107bde;
    box-shadow: 0 4px 10px rgba(61, 98, 133, 0.30);
}
.state-pill svg {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
}

/* Dark */
[data-theme="dark"] .state-pill > span {
    background: #262a30;
    color: var(--muted);
    border-color: var(--line);
}
[data-theme="dark"] .state-pill:hover > span {
    background: #2a2e35;
    border-color: #3a3f46;
}

/* Mobile: le pill restano larghe, vanno bene */
@media (max-width: 700px) {
    .state-pills {
        height: 48px;
    }
    .state-pill > span {
        font-size: 13px;
        padding: 0 10px;
    }
    .state-pill svg {
        width: 14px;
        height: 14px;
    }
}
/* ============================================================
   v37 — Modale data visione
   ============================================================ */
.modal-icon-info {
    background: #fff8e6;
    color: #c89a2a;
}
[data-theme="dark"] .modal-icon-info {
    background: #3a2e1a;
    color: #e0b95a;
}
.watched-date-field {
    margin: 4px 0 22px;
}
.watched-date-field input[type="date"] {
    width: 100%;
    height: 46px;
    padding: 0 13px;
    font: 500 14px "DM Sans", sans-serif;
    color: var(--ink);
    background: #fbfbfa;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.watched-date-field input[type="date"]:focus {
    background: white;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, 0.13);
}
[data-theme="dark"] .watched-date-field input[type="date"] {
    background: #262a30;
    color: var(--ink);
    color-scheme: dark;
}
[data-theme="dark"] .watched-date-field input[type="date"]:focus {
    background: #262a30;
}
/* ============================================================
   v38 — Etichette specifiche nell'autocomplete
   ============================================================ */

/* Variante "Nei visti" (default, già definita) */
.already-label-watched {
    color: var(--olive);
    background: #eff2eb;
}

/* Variante "Da vedere" */
.already-label-towatch {
    color: #a05a2c;
    background: #fbe9dd;
}

[data-theme="dark"] .already-label-towatch {
    background: #3a2820;
    color: #e8a06a;
}
/* ============================================================
   v39 — Layout form aggiunta: Dettagli allineato al Voto
   ============================================================ */
.title-form {
    display: grid;
    grid-template-columns: 1.5fr 1.1fr 0.9fr auto;
    grid-template-areas:
        "title state rating ."
        "add clear details .";
    gap: 13px 16px;
    align-items: end;
    max-width: 900px;
}
.field-title { grid-area: title; }
.state-field { grid-area: state; }
.rating-field { grid-area: rating; min-width: 130px; }
.title-form > .primary-button { grid-area: add; }
.details-form-btn { grid-area: details; }
.clear-form-btn { grid-area: clear; }

.state-pills { max-width: none; }
.rating-input { max-width: none; }

/* Tutti i pulsanti della riga 2: stessa altezza, stessa larghezza del campo sopra */
.title-form > .primary-button,
.clear-form-btn,
.details-form-btn {
    width: 100%;
    height: 46px;
    padding: 0 24px;
    font-size: 14px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Dettagli: pieno scuro, testo bianco */
.details-form-btn {
    background: #2a2f37;
    color: white;
    border: 1px solid #2a2f37;
    text-decoration: none;
    gap: 6px;
}
.details-form-btn:hover {
    background: #1f2329;
    color: white;
    border-color: #1f2329;
}
.details-form-btn svg { flex-shrink: 0; }

[data-theme="dark"] .details-form-btn {
    background: #3a4048;
    color: white;
    border-color: #3a4048;
}
[data-theme="dark"] .details-form-btn:hover {
    background: #4a5058;
    border-color: #4a5058;
}

/* Mobile: tutto in colonna */
@media (max-width: 700px) {
    .title-form {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .title-form > * { width: 100%; }
}
/* ============================================================
   v40 — Fix mobile (ricerca, filtri) + troncamento + dettagli
   ============================================================ */

/* --- 1. Su mobile, il campo di ricerca non deve "gonfiarsi" --- */
@media (max-width: 700px) {
    .list-search {
        flex: 0 0 auto;
        max-width: none;
        width: 100%;
        height: 48px;
    }
    /* Stesso fix per filtri avanzati */
    .filter-field,
    .filter-checks {
        flex: 0 0 auto;
        min-width: 0;
        width: 100%;
    }
    .filters-panel {
        gap: 14px;
    }
    .filter-field select {
        height: 46px;
    }
}

/* --- 2. Troncamento titoli lunghi --- */

/* Vista compatta: 1 riga sola con 3 puntini */
.titles-list.view-compact .title-main {
    min-width: 0;
    overflow: hidden;
}
.titles-list.view-compact .title-main strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Vista griglia: già usa -webkit-line-clamp, ma rafforziamo */
.titles-list.view-grid .title-main strong {
    max-width: 100%;
    overflow: hidden;
}

/* Vista schede (desktop + mobile): tronca a 1 riga */
.title-item .title-main {
    min-width: 0;
}
.title-item .title-main strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- 3. Mobile: Dettagli sotto il Titolo --- */
@media (max-width: 700px) {
    .title-form {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .field-title { order: 1; }
    .details-form-btn { order: 2; }
    .state-field { order: 3; }
    .rating-field { order: 4; }
    .title-form > .primary-button { order: 5; }
    .clear-form-btn { order: 6; }
}

/* --- 4. Dettagli: arancione più tenue (mobile + desktop) --- */
.details-form-btn {
    background: #d99578;
    color: white;
    border: 1px solid #d99578;
}
.details-form-btn:hover {
    background: #c47f61;
    border-color: #c47f61;
}
[data-theme="dark"] .details-form-btn {
    background: #b88570;
    color: white;
    border-color: #b88570;
}
[data-theme="dark"] .details-form-btn:hover {
    background: #a27360;
    border-color: #a27360;
}
/* ============================================================
   v41 — Avatar in user-bar + pagina profilo
   ============================================================ */

/* --- Avatar in user-bar --- */
.user-avatar-link {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    text-decoration: none;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.user-avatar-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.user-avatar-initial {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    background: var(--accent);
    color: white;
    font: 700 14px "DM Sans", sans-serif;
}
.user-greeting {
    text-decoration: none;
    color: var(--muted);
    font-size: 13px;
    transition: color 0.15s ease;
}
.user-greeting:hover { color: var(--accent); }
.user-greeting strong { color: var(--ink); }

/* --- Pagina profilo: header con avatar grande --- */
.profile-header-card {
    padding: 28px;
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}
.profile-avatar-big {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--soft-orange);
}
.profile-avatar-big img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.profile-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: white;
    font: 700 36px "Playfair Display", serif;
}
.profile-header-info h2 {
    font-family: "Playfair Display", serif;
    font-size: 26px;
    margin: 0 0 4px;
}
.profile-header-info p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 14px;
}
.profile-joined {
    font-size: 12px !important;
    opacity: 0.7;
}

/* --- Form del profilo --- */
.profile-form {
    display: grid;
    gap: 18px;
}
.profile-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.field-hint {
    font-size: 11px;
    color: var(--muted);
    margin: 6px 0 0;
    line-height: 1.4;
}

/* --- Mobile --- */
@media (max-width: 700px) {
    .profile-header-card {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 24px 18px;
    }
    .profile-form-row {
        grid-template-columns: 1fr;
    }
    .user-bar {
        gap: 8px;
    }
    .user-greeting {
        font-size: 12px;
    }
        .profile-header-actions {
        margin-left: 0;
        width: 100%;
        align-items: stretch;
    }
    .profile-header-actions .profile-stats-btn {
        justify-content: center;
    }
}
/* ============================================================
   v42 — Spazio tra form consecutivi nella pagina profilo
   ============================================================ */
section.form-card + section.form-card {
    margin-top: 24px;
}

@media (max-width: 700px) {
    section.form-card + section.form-card {
        margin-top: 18px;
    }
}
/* ============================================================
   v43 — Avatar zoom + Watchlist card + Collapsible profile forms
   ============================================================ */

/* --- Avatar cliccabile --- */
.profile-avatar-clickable {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.profile-avatar-clickable:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* --- Modale avatar --- */
.modal-box-avatar {
    position: relative;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    /* Si adatta alla dimensione dell'immagine, così l'X resta vicino */
    width: fit-content;
    max-width: 90vw;
    max-height: 90vh;
    margin: 0 auto;
    display: inline-block;
}
.modal-box-avatar img {
    display: block;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* X più visibile e vicina all'immagine */
.modal-box-avatar .modal-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: background 0.15s ease, transform 0.15s ease;
}
.modal-box-avatar .modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.95);
    transform: scale(1.05);
}

@media (max-width: 700px) {
    .modal-box-avatar .modal-close-btn {
        top: 6px;
        right: 6px;
        width: 36px;
        height: 36px;
        font-size: 22px;
    }
}

/* --- Watchlist card nel profilo --- */
.watchlist-card-section {
    margin-bottom: 24px;
}
.watchlist-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
    background: var(--card);
    border: 2px solid #107bde;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--ink);
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        color var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.watchlist-card:hover {
    background: #107bde;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(16, 123, 222, 0.25);
}
.watchlist-card-icon {
    font-size: 26px;
    line-height: 1;
    flex-shrink: 0;
}
.watchlist-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.watchlist-card-label {
    font-family: "Playfair Display", serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.watchlist-card-desc {
    font-size: 13px;
    opacity: 0.8;
}
.watchlist-card-count {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    background: #107bde;
    color: white;
    border-radius: 19px;
    font: 700 16px "DM Sans", sans-serif;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.watchlist-card:hover .watchlist-card-count {
    background: white;
    color: #107bde;
}

/* --- Mobile adjustments --- */
@media (max-width: 700px) {
    .watchlist-card {
        padding: 14px 16px;
        gap: 12px;
    }
    .watchlist-card-label { font-size: 18px; }
    .watchlist-card-icon { font-size: 22px; }
    .watchlist-card-count {
        min-width: 34px;
        height: 34px;
        font-size: 14px;
    }
}

/* --- Collapsible profile cards --- */
.profile-collapsible-card {
    padding: 0;
    overflow: hidden;
}
.profile-collapsible-card + .profile-collapsible-card {
    margin-top: 24px;
}
.profile-collapsible-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 20px 26px;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    color: var(--ink);
    font: inherit;
}
.profile-collapsible-header {
    display: flex;
    align-items: center;
    gap: 16px;
}
.profile-collapsible-icon {
    font-size: 26px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--soft-orange);
    border-radius: 12px;
    flex-shrink: 0;
}
.profile-collapsible-desc {
    font-size: 13px;
    color: var(--muted);
    margin: 4px 0 0;
}
.profile-collapsible-chevron {
    transition: transform 300ms ease;
    color: var(--muted);
    flex-shrink: 0;
}
.profile-collapsible-card.open .profile-collapsible-chevron {
    transform: rotate(180deg);
}
.profile-collapsible-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 400ms ease;
}
.profile-collapsible-card.open .profile-collapsible-body {
    max-height: 1000px;  /* abbastanza per contenere il form */
}
.profile-collapsible-inner {
    padding: 0 26px 26px;
}

/* --- Mobile adjustments --- */
@media (max-width: 700px) {
    .profile-collapsible-toggle {
        padding: 16px 18px;
    }
    .profile-collapsible-icon {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }
    .profile-collapsible-inner {
        padding: 0 18px 20px;
    }
    .profile-collapsible-card + .profile-collapsible-card {
        margin-top: 18px;
    }
}
/* ============================================================
   v44 — Switcher tab in stile GitHub (Visti / Anime)
   ============================================================ */
.list-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}
.list-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    color: var(--muted);
    text-decoration: none;
    font: 600 14px "DM Sans", sans-serif;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.list-tab:hover {
    color: var(--ink);
}
.list-tab.active {
    color: var(--ink);
    border-bottom-color: var(--accent);
}
.list-tab-count {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    background: var(--soft-orange);
    color: var(--accent);
    border-radius: 11px;
    font: 700 11px "DM Sans", sans-serif;
}
.list-tab.active .list-tab-count {
    background: var(--accent);
    color: white;
}

[data-theme="dark"] .list-tab-count {
    background: #3a2820;
    color: var(--accent);
}
[data-theme="dark"] .list-tab.active .list-tab-count {
    background: var(--accent);
    color: #1a1a1a;
}

@media (max-width: 700px) {
    .list-tabs {
        margin-bottom: 18px;
    }
    .list-tab {
        flex: 1;
        justify-content: center;
        padding: 12px 10px;
        font-size: 13px;
    }
}
/* ============================================================
   v45 — Toggle "Questo è un anime" nel form di modifica
   ============================================================ */
.field-anime {
    grid-column: 1 / -1;
    padding: 14px 16px;
    background: var(--soft-orange);
    border: 1px solid #f0c4b6;
    border-radius: 10px;
}
.anime-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.anime-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}
.anime-check span {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
}
.field-anime .field-hint {
    margin: 6px 0 0 28px;
}

[data-theme="dark"] .field-anime {
    background: #3a2820;
    border-color: rgba(255, 132, 101, 0.35);
}
/* ============================================================
   v46 — Stats tabs + Watchlist filters
   ============================================================ */

/* Stats tabs */
.stats-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
}
.stats-tab {
    padding: 10px 18px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font: 600 14px "DM Sans", sans-serif;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.stats-tab:hover {
    color: var(--ink);
}
.stats-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Watchlist filters */
.watchlist-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    padding: 0 4px;
    flex-wrap: wrap;
}
.watchlist-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font: 600 13px "DM Sans", sans-serif;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.watchlist-filter:hover {
    background: #f5f5f3;
    color: var(--ink);
}
.watchlist-filter.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.watchlist-filter-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    background: var(--soft-orange);
    color: var(--accent);
    border-radius: 10px;
    font: 700 11px "DM Sans", sans-serif;
}
.watchlist-filter.active .watchlist-filter-count {
    background: white;
    color: var(--accent);
}

/* Dark */
[data-theme="dark"] .watchlist-filter:hover {
    background: #262a30;
    color: var(--ink);
}

@media (max-width: 700px) {
    .stats-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .stats-tab {
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
    }
}
/* ============================================================
   v47 — Filtri tipo dentro il pannello filtri
   ============================================================ */
.filters-panel .list-filters {
    margin-top: 6px;
    background: transparent;
    border: 0;
    padding: 0;
}
.filters-panel .list-filters .filter-btn {
    background: #fbfbfa;
    border: 1px solid var(--line);
}
.filters-panel .list-filters .filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

[data-theme="dark"] .filters-panel .list-filters .filter-btn {
    background: #262a30;
    border-color: var(--line);
}
[data-theme="dark"] .filters-panel .list-filters .filter-btn.active {
    background: var(--accent);
    color: #1a1a1a;
    border-color: var(--accent);
}
/* ============================================================
   v48 — User-bar sticky (profilo, dettagli, watchlist, recommendations)
   ============================================================ */
.user-bar.user-bar-sticky {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(248, 248, 245, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 12px 0;
    margin-top: -12px;
    margin-bottom: 12px;
}
[data-theme="dark"] .user-bar.user-bar-sticky {
    background: rgba(21, 23, 26, 0.88);
}

@media (max-width: 700px) {
    .user-bar.user-bar-sticky {
        padding: 10px 0;
        margin-top: -10px;
        margin-bottom: 10px;
    }
}
/* ============================================================
   v49 — Badge "con nota" sui titoli
   ============================================================ */
.note-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    background: #fff8ec;
    color: #a07000;
    border: 1px solid #f0dba8;
    border-radius: 6px;
    font: 700 10px "DM Sans", sans-serif;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}
.note-badge svg { flex-shrink: 0; }

[data-theme="dark"] .note-badge {
    background: #3a2e1a;
    color: #e0b95a;
    border-color: rgba(224, 185, 90, 0.4);
}

/* In viste compatte e griglia, il badge può dare fastidio: nascondilo */
.titles-list.view-compact .note-badge,
.titles-list.view-grid .note-badge,
.titles-list.view-sagas .note-badge {
    display: none;
}
/* Animazione di entrata delle card durante ricerca/filtro */
@keyframes filterItemEnter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.title-item.filter-enter {
    animation: filterItemEnter 0.28s ease both;
}

.saga-group.filter-enter {
    animation: filterItemEnter 0.28s ease both;
}

@media (prefers-reduced-motion: reduce) {
    .saga-group.filter-enter {
        animation: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .title-item.filter-enter {
        animation: none;
    }
}
/* ---------- Filtro attore separato ---------- */
.actor-filter-wrap {
    position: relative;
    min-width: 170px;
    flex: 1 1 170px;
    max-width: 220px;
}

.actor-search {
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(128, 128, 128, 0.28);
    background: rgba(128, 128, 128, 0.08);
    color: inherit;
    font-size: 0.9rem;
    font-family: inherit;
}

.actor-search::placeholder {
    color: rgba(128, 128, 128, 0.75);
}

.actor-search:focus {
    outline: none;
    border-color: #ff7a59;
}

.actor-chip {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #ff7a59;
    background: rgba(255, 122, 89, 0.14);
    color: inherit;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
}

.actor-chip:hover {
    background: rgba(255, 122, 89, 0.24);
}

.actor-chip-x {
    font-size: 1.05rem;
    line-height: 1;
    opacity: 0.75;
}

.actor-chip:hover .actor-chip-x {
    opacity: 1;
}
.actor-chip[hidden] {
    display: none !important;
}

.actor-search[hidden] {
    display: none !important;
}
.actor-autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: rgba(30, 30, 30, 0.98);
    border: 1px solid rgba(128, 128, 128, 0.28);
    border-radius: 10px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.actor-autocomplete-list.open {
    display: block;
}

.actor-autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.12);
}

.actor-autocomplete-item:last-child {
    border-bottom: none;
}

.actor-autocomplete-item:hover {
    background: rgba(128, 128, 128, 0.16);
}

.actor-autocomplete-empty {
    padding: 10px 12px;
    font-size: 0.85rem;
    opacity: 0.6;
}
/* ---------- Pagina Scopri ---------- */
.discover-section {
    position: relative;
    margin: 2.6rem 0;
    padding: 1.2rem 1.1rem 0.6rem 1.1rem;
    border-radius: 18px;
    background: rgba(128, 128, 128, 0.06);
    border: 1px solid rgba(128, 128, 128, 0.14);
}

@media (max-width: 600px) {
    .discover-section {
        margin: 1.8rem 0;
        padding: 1rem 0.8rem 0.4rem 0.8rem;
        border-radius: 14px;
    }
}

.discover-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 0.9rem 0;
    padding: 0 0.2rem;
    display: flex;
    align-items: center;
    gap: 14px;
}

.discover-empty {
    font-size: 0.9rem;
    opacity: 0.6;
    padding: 0.5rem 0.2rem;
}

.discover-scroll {
    display: flex;
    gap: 0.9rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.3rem 0.2rem 1rem 0.2rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.discover-scroll:hover {
    scrollbar-color: rgba(128, 128, 128, 0.45) transparent;
}

.discover-scroll::-webkit-scrollbar {
    height: 8px;
}

.discover-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.discover-scroll::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.discover-scroll:hover::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.45);
}

.discover-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.65);
}

@media (max-width: 700px) {
    .discover-scroll {
        scrollbar-width: none;
    }
    .discover-scroll::-webkit-scrollbar {
        display: none;
    }
}

.discover-card {
    flex: 0 0 auto;
    width: 140px;
    text-decoration: none;
    color: inherit;
    scroll-snap-align: start;
    transition: transform 0.2s ease;
}

.discover-card:hover {
    transform: translateY(-3px);
}

.discover-poster {
    position: relative;
    width: 140px;
    height: 210px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.15);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.discover-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.discover-vote {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
}

.discover-poster .to-watch-badge-blue {
    left: 6px;
    right: auto;
    background: rgba(16, 123, 222, 0.92);
    color: #fff;
}

.discover-info {
    padding: 0.5rem 0.15rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.discover-info strong {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.discover-meta {
    font-size: 0.74rem;
    opacity: 0.65;
}

@media (max-width: 600px) {
    .discover-card,
    .discover-poster {
        width: 120px;
    }
    .discover-poster {
        height: 180px;
    }
}
/* ---------- Switch Home ⇄ Scopri ---------- */
.page-switch {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(128, 128, 128, 0.14);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.page-switch-btn {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 62px;
    height: auto;
    padding: 6px 12px 5px;
    border-radius: 10px;
    color: inherit;
    opacity: 0.7;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    transition:
        opacity 0.18s ease,
        background 0.22s ease,
        transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.22s ease;
}

.page-switch-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.35) 0%, transparent 65%);
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

.page-switch-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.page-switch-btn:active {
    transform: scale(0.94);
}

.page-switch-btn:active::before {
    opacity: 1;
    transform: scale(1.6);
    transition: opacity 0.12s ease, transform 0.45s ease;
}

.page-switch-btn.active {
    opacity: 1;
    background: #ff7a59;
    color: #fff;
    box-shadow:
        0 3px 12px rgba(255, 122, 89, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.page-switch-btn.active:hover {
    background: #ff8a6b;
}
.page-switch-label {
    font-size: 0.66rem;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.02em;
    opacity: 0.9;
}

/* Da: @media (max-width: 1023px) { */
@media (max-width: 900px) {
    .page-switch-btn {
        flex-direction: row;
        gap: 6px;
        min-width: 56px;
        height: 32px;
        padding: 0 12px;
    }
    .page-switch-label {
        display: none;
    }
}

@media (max-width: 480px) {
    .page-switch {
        padding: 4px;
        gap: 4px;
    }
    .page-switch-btn {
        min-width: 56px;
        height: 30px;
        padding: 0 10px;
        font-size: 0.8rem;
    }
}
/* ---------- Avatar grande in home ---------- */
.user-info-avatar-only {
    margin-left: auto;
}

.user-avatar-lg {
    width: 46px;
    height: 46px;
}

.user-avatar-lg .user-avatar-img,
.user-avatar-lg .user-avatar-initial {
    width: 46px;
    height: 46px;
    font-size: 1.15rem;
}

@media (max-width: 480px) {
    .user-avatar-lg,
    .user-avatar-lg .user-avatar-img,
    .user-avatar-lg .user-avatar-initial {
        width: 40px;
        height: 40px;
    }
}

/* ---------- Toast "Ciao, username" ---------- */
.welcome-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 999px;
    background: rgba(30, 30, 30, 0.92);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 9999;
    pointer-events: none;
    animation: welcomeFade 4s ease forwards;
}

.welcome-toast strong {
    color: #ff7a59;
}

@keyframes welcomeFade {
    0%   { opacity: 0; transform: translate(-50%, -10px) scale(0.94); }
    12%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
    80%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -10px) scale(0.96); }
}

/* ---------- Tasto Esci grande nel profilo ---------- */
.profile-logout-section {
    display: flex;
    justify-content: flex-end;
    margin: 2rem 0 1rem 0;
}

.logout-btn-big {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid rgba(220, 90, 90, 0.5);
    background: rgba(220, 90, 90, 0.1);
    color: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.logout-btn-big:hover {
    background: rgba(220, 90, 90, 0.2);
    border-color: rgba(220, 90, 90, 0.8);
}

.logout-btn-big:active {
    transform: scale(0.97);
}
/* ---------- Tasto Stats nel profilo ---------- */
.profile-header-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-stats-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid rgba(128, 128, 128, 0.28);
    background: rgba(128, 128, 128, 0.1);
    color: inherit;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.profile-stats-btn:hover {
    background: rgba(255, 122, 89, 0.12);
    border-color: rgba(255, 122, 89, 0.5);
}

.profile-stats-btn:active {
    transform: scale(0.96);
}

/* ---------- Modale Stats ---------- */
.modal-box-stats {
    max-width: 720px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.6rem 1.6rem 2rem 1.6rem;
}

.modal-box-stats .stats-title {
    margin-top: 0;
    padding-right: 2rem;
}
/* ---------- Rifiniture modale Stats ---------- */

/* Angoli smussati su tutti i lati + scrollbar custom */
.modal-box-stats {
    position: relative;
    border-radius: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

/* Scrollbar solo al passaggio del mouse (Firefox) */
.modal-box-stats:hover {
    scrollbar-color: rgba(128, 128, 128, 0.4) transparent;
}

/* Scrollbar solo al passaggio del mouse (Chrome/Safari/Edge) */
.modal-box-stats::-webkit-scrollbar {
    width: 8px;
}

.modal-box-stats::-webkit-scrollbar-track {
    background: transparent;
}

.modal-box-stats::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.modal-box-stats:hover::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.4);
}

.modal-box-stats::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.6);
}

/* X in alto a destra, arancione, coerente con lo stile dell'app */
.modal-box-stats .modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    left: auto;
    transform: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid rgba(255, 122, 89, 0.5);
    background: transparent;
    color: #ff7a59;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
    z-index: 2;
}

.modal-box-stats .modal-close-btn:hover {
    background: rgba(255, 122, 89, 0.15);
    border-color: rgba(255, 122, 89, 0.9);
}

.modal-box-stats .modal-close-btn:active {
    transform: scale(0.94);
}
/* ---------- Frecce di scroll su Scopri ---------- */

.discover-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(128, 128, 128, 0.28);
    background: rgba(30, 30, 30, 0.82);
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0.6;
    transition: opacity 0.18s ease, background 0.18s ease, transform 0.12s ease;
}

.discover-scroll-wrap:hover .discover-arrow {
    opacity: 1;
}

.discover-arrow:hover {
    background: rgba(60, 60, 60, 0.95);
    border-color: rgba(255, 122, 89, 0.6);
}

.discover-arrow:active {
    transform: translateY(-50%) scale(0.92);
}

.discover-arrow[disabled] {
    opacity: 0;
    pointer-events: none;
}

.discover-arrow-left {
    left: 12px;
}

.discover-arrow-right {
    right: 12px;
}

@media (max-width: 700px) {
    .discover-arrow {
        width: 28px;
        height: 28px;
        opacity: 0.4;
    }
    .discover-arrow-left { left: 6px; }
    .discover-arrow-right { right: 6px; }
}
.discover-title-accent {
    color: #ff7a59;
}
/* ============================================================
   v50 — Link "Esporta CSV" nella card profilo
   ============================================================ */
.profile-export-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--soft-orange);
    color: var(--accent);
    border: 1px solid #f0c4b6;
    border-radius: 10px;
    font: 700 12px "DM Sans", sans-serif;
    letter-spacing: .02em;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition:
        background var(--dur-fast) var(--ease-out-soft),
        color var(--dur-fast) var(--ease-out-soft),
        border-color var(--dur-fast) var(--ease-out-soft),
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}
.profile-export-link:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(233, 111, 77, .25);
}

[data-theme="dark"] .profile-export-link {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: rgba(255, 132, 101, 0.35);
}
[data-theme="dark"] .profile-export-link:hover {
    background: var(--accent);
    color: #1a1a1a;
    border-color: var(--accent);
}

@media (max-width: 700px) {
    .profile-export-link {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
}
/* ============================================================
   v51 — Fix altezza campo attore su mobile
   ============================================================ */
@media (max-width: 700px) {
    .actor-filter-wrap {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
        min-width: 0;
    }
}
/* ============================================================
   v52 — Filtri: Ordina per + Attore dentro il pannello
   ============================================================ */
.filter-field-actor .actor-filter-wrap {
    min-width: 0;
    max-width: none;
    flex: 0 0 auto;
    width: 100%;
}
.filters-panel .filter-field select#list-sort {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 42px;
    background: #fbfbfa;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 9px;
    font: 500 13px "DM Sans", sans-serif;
    cursor: pointer;
    outline: none;
}
[data-theme="dark"] .filters-panel .filter-field select#list-sort {
    background: #262a30;
    color: var(--ink);
}
.filters-panel .filter-field select#list-sort:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, .13);
}
/* ============================================================
   v53 — Filtri avanzati (sotto-pannello collassabile)
   ============================================================ */
.filters-advanced-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 100%;
    height: 32px;
    padding: 0 6px;
    background: transparent;
    color: var(--muted);
    border: 0;
    border-radius: 6px;
    font: 700 12px "DM Sans", sans-serif;
    letter-spacing: .04em;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--dur-fast) ease;
}
.filters-advanced-toggle:hover {
    color: var(--accent);
}
.filters-advanced-toggle[aria-expanded="true"] {
    color: var(--accent);
}
.filters-advanced-toggle svg {
    transition: transform 250ms ease;
}
.filters-advanced-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}
.filters-advanced-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    font: 700 10px "DM Sans", sans-serif;
}
.filters-advanced-count[hidden] {
    display: none !important;
}

/* --- Pannello avanzato: griglia desktop --- */
.filters-advanced-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 240px));
    justify-content: center;
    grid-template-areas: "decade actor rating";
    gap: 16px 22px;
    align-items: end;
    flex: 1 1 100%;
    width: 100%;
    padding-top: 4px;
    animation: fadeUp 250ms ease;
}

.filters-advanced-panel > .filter-field:nth-child(1) { grid-area: decade; }
.filters-advanced-panel > .filter-field:nth-child(2) { grid-area: actor; }
.filters-advanced-panel > .filter-field:nth-child(3) { grid-area: rating; }

/* Checkbox affiancate */
.filters-advanced-panel .filter-checks {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.filters-advanced-panel[hidden] {
    display: none !important;
}

/* --- Dark --- */
[data-theme="dark"] .filters-advanced-toggle:hover {
    color: var(--accent);
}
[data-theme="dark"] .filters-advanced-toggle[aria-expanded="true"] {
    color: var(--accent);
}

/* --- Mobile --- */
@media (max-width: 700px) {
    .filters-advanced-toggle {
        margin: 4px auto 0;
        align-self: center;
        flex: 0 0 auto;
    }
    .filters-advanced-panel {
        grid-template-columns: 1fr;
        grid-template-areas:
            "decade"
            "type"
            "rating"
            "checks"
            "reset";
        gap: 14px;
        padding-top: 10px;
    }
    .filters-advanced-panel .filter-checks {
        flex-direction: row;
        flex-wrap: wrap;
    }
}
/* ============================================================
   v54 — Condivisione titolo
   ============================================================ */

/* Pulsante "Condividi" nel dettaglio */
.detail-share-row {
    margin-top: 14px;
}
.detail-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 11px;
    font: 700 13px "DM Sans", sans-serif;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition:
        background var(--dur-fast) ease,
        transform var(--dur-base) var(--ease-smooth);
}
.detail-share-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}
.detail-share-btn.copied {
    background: var(--accent);
    border-color: var(--accent);
}

/* Pagina condivisa: header minimale */
.shared-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 32px;
    gap: 4px;
}
.shared-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
}
.shared-brand .brand-mark {
    margin: 0;
}
.shared-brand-text {
    font-family: "Playfair Display", serif;
    font-size: 22px;
    letter-spacing: -0.02em;
}
.shared-brand-text em {
    color: var(--accent);
    font-style: italic;
}
.shared-tagline {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 6px 0 0;
}

/* CTA finale sulla pagina condivisa */
.shared-cta {
    text-align: center;
    margin: 52px 0 24px;
    padding: 32px 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
}
.shared-cta-text {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 16px;
}
.shared-cta .detail-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
@media (max-width: 700px) {
    .detail-share-btn {
        width: 100%;
        justify-content: center;
    }
}
/* ============================================================
   v55 — Avatar utente nel titolo di Scopri
   ============================================================ */
.discover-user-avatar-wrap {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.discover-user-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #ff7a59;
    background: var(--soft-orange);
    box-sizing: border-box;
}
.discover-user-avatar-star {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    padding: 2px;
    background: var(--card);
    border: 2px solid #ff7a59;
    border-radius: 50%;
    box-sizing: content-box;
    display: block;
}
.discover-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.discover-user-avatar span {
    color: #ff7a59;
    font: 700 13px "DM Sans", sans-serif;
    line-height: 1;
}
.profile-header-actions {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}
.profile-header-actions .profile-export-link {
    margin-left: 0;
}
/* ============================================================
   v56 — Troncamento titoli a 1 riga (schede, griglia, compatta)
   ============================================================ */

/* Tutte le viste: forza troncamento a 1 riga con i 3 puntini */
.title-item .title-main strong,
.titles-list.view-grid .title-main strong,
.titles-list.view-sagas .title-main strong,
.titles-list.view-compact .title-main strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    min-width: 0;
}

/* Il link che contiene il titolo deve poter restringersi */
.title-item .title-link {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Il contenitore del titolo: assicura che non si allarghi */
.title-item .title-main {
    min-width: 0;
    max-width: 100%;
}

/* In griglia/saghe, il contenitore titolo è block: ok */
.titles-list.view-grid .title-main,
.titles-list.view-sagas .title-main {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
/* ============================================================
   v57 — Indicatore rewatch discreto (come data visione)
   ============================================================ */
.title-rewatch {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 500;
}
.title-rewatch svg {
    color: #b8b6ad;
    flex-shrink: 0;
}

/* Dark mode */
[data-theme="dark"] .title-rewatch svg {
    color: #6a7079;
}
/* ============================================================
   v58 — Toggle "Includi titoli senza data di visione" (stats)
   ============================================================ */
.stats-pref-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 10px 14px;
    background: #fbfbfa;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.stats-pref-toggle:hover {
    background: #f5f5f2;
}
.stats-pref-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}
.stats-pref-toggle span {
    line-height: 1.4;
}
.stats-pref-toggle small {
    opacity: 0.75;
}

/* Dark */
[data-theme="dark"] .stats-pref-toggle {
    background: #262a30;
    border-color: var(--line);
}
[data-theme="dark"] .stats-pref-toggle:hover {
    background: #2a2e35;
}
/* ============================================================
   v59 — Menù "⋯" sulla card titolo
   ============================================================ */
.title-menu-wrap {
    position: relative;
    display: inline-flex;
}

.icon-btn-menu {
    color: #a2a6aa;
}
.icon-btn-menu:hover {
    background: #f5f5f3;
    color: var(--ink);
    border-color: #d5d5d0;
}
.icon-btn-menu[aria-expanded="true"] {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: #f0c4b6;
}

/* Pannello che si apre verso l'alto */
.title-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 190px;
    padding: 5px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 11px;
    box-shadow: 0 14px 36px rgba(39, 44, 50, 0.18);
    z-index: 30;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transform-origin: bottom right;
    pointer-events: none;
    transition:
        opacity 180ms ease,
        transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.title-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.title-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 7px;
    text-decoration: none;
    font: 500 13px "DM Sans", sans-serif;
    text-align: left;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}
.title-menu-item:hover {
    background: var(--soft-orange);
    color: var(--accent);
}
.title-menu-item svg {
    flex-shrink: 0;
    color: var(--muted);
    transition: color 150ms ease;
}
.title-menu-item:hover svg {
    color: var(--accent);
}

/* Dark */
[data-theme="dark"] .icon-btn-menu:hover {
    background: #262a30;
    color: var(--ink);
    border-color: #3a3f46;
}
[data-theme="dark"] .icon-btn-menu[aria-expanded="true"] {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: rgba(255, 132, 101, 0.35);
}
[data-theme="dark"] .title-menu {
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}

/* Mobile: leggermente più largo per il tocco */
@media (max-width: 700px) {
    .title-menu {
        min-width: 200px;
    }
    .title-menu-item {
        padding: 12px 14px;
        font-size: 14px;
    }
}
/* ============================================================
   v60 — Fix menù su vista griglia/saghe (overflow)
   ============================================================ */

/* Il menu deve poter uscire dalla card: niente overflow hidden */
.titles-list.view-grid .title-item,
.titles-list.view-sagas .title-item {
    overflow: visible;
}

/* L'arrotondamento in alto ora sta sul poster (era sulla card) */
.titles-list.view-grid .title-poster,
.titles-list.view-sagas .title-poster {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* Il menù chiuso non deve essere cliccabile né visibile */
.title-menu:not(.open) {
    visibility: hidden;
}
.title-menu.open {
    visibility: visible;
}

/* Alza il menù sopra tutto dentro la card */
.title-menu-wrap {
    z-index: 5;
}
.title-menu {
    z-index: 40;
}
/* ============================================================
   v61 — Fix troncamento universale + riga separatrice più lunga
   ============================================================ */

/* ---------- 1. Catena di contenimento ---------- */
.title-item .title-info,
.title-item .title-main {
    min-width: 0;
    max-width: 100%;
}

/* ---------- 2. Link: block SENZA overflow hidden
   (lascia che sia il <strong> a clippare con ellipsis) ---------- */
.title-item .title-main > .title-link {
    display: block;
    min-width: 0;
    max-width: 100%;
}

/* ---------- 3. Titolo: strong block, 1 riga, ellipsis ---------- */
.title-item .title-main > strong,
.title-item .title-main > .title-link > strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    min-width: 0;
}

/* ---------- 4. Override esplicito delle viste griglia/saghe ---------- */
.titles-list.view-grid .title-main,
.titles-list.view-sagas .title-main {
    min-height: 0;
}
.titles-list.view-grid .title-main strong,
.titles-list.view-sagas .title-main strong {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    -webkit-box-orient: initial;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- 5. Meta (anno/genere/voto): ellipsis ---------- */
.title-item .title-meta {
    min-width: 0;
    max-width: 100%;
}

.title-item .meta-item {
    display: inline-block;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.titles-list.view-grid .meta-item,
.titles-list.view-sagas .meta-item {
    display: block;
    max-width: 100%;
}

.titles-list.view-grid .title-meta,
.titles-list.view-sagas .title-meta {
    align-items: stretch;
    min-width: 0;
}

/* ---------- 6. Riga separatrice più lunga in griglia/saghe ---------- */
.titles-list.view-grid .title-footer,
.titles-list.view-sagas .title-footer {
    margin-left: 0;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 24px;
    box-sizing: border-box;
}

@media (max-width: 700px) {
    .titles-list.view-grid .title-footer,
    .titles-list.view-sagas .title-footer {
        margin-left: 0;
        margin-right: -10px;
        padding-left: 10px;
        padding-right: 20px;
    }
}
/* ============================================================
   v62 — Pagina di modifica: sezioni + campi bloccati
   ============================================================ */

/* --- Il form non usa più la griglia globale: layout pulito --- */
.edit-card .title-form {
    display: block;
    max-width: none;
    gap: 0;
}

/* --- Sezione --- */
.form-section {
    padding: 22px 0;
    border-top: 1px solid var(--line);
}
.form-section:first-of-type {
    padding-top: 6px;
    border-top: 0;
}
.form-section:last-of-type {
    padding-bottom: 6px;
}

.form-section-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}
.form-section-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: var(--soft-orange);
    color: var(--accent);
    border-radius: 10px;
}
.form-section-label {
    font-family: "Playfair Display", serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    line-height: 1.1;
}
.form-section-desc {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 0;
}

/* --- Corpo della sezione: griglia 2 colonne --- */
.form-section-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
    align-items: end;
}
.form-section-body .form-field-full {
    grid-column: 1 / -1;
}

/* --- Campi bloccati (readonly / disabled) --- */
.field-locked,
select[disabled],
input[readonly].field-locked {
    background: rgba(128, 128, 128, 0.08) !important;
    color: var(--muted) !important;
    cursor: not-allowed;
    border-color: var(--line);
}
.field-locked:focus,
select[disabled]:focus {
    box-shadow: none;
    border-color: var(--line);
    background: rgba(128, 128, 128, 0.08) !important;
}

/* Nota sotto il campo bloccato */
.field-hint-locked {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    margin: 6px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* --- Il campo note: textarea a piena larghezza --- */
.form-section-body .field-notes textarea {
    width: 100%;
}

/* --- Riquadro anime: non deve occupare solo metà --- */
.form-section-body .field-anime {
    grid-column: 1 / -1;
    padding: 14px 16px;
    background: var(--soft-orange);
    border: 1px solid #f0c4b6;
    border-radius: 10px;
}

/* --- Dark --- */
[data-theme="dark"] .field-locked,
[data-theme="dark"] select[disabled],
[data-theme="dark"] input[readonly].field-locked {
    background: rgba(255, 255, 255, 0.04) !important;
    color: var(--muted) !important;
}
[data-theme="dark"] .form-section-body .field-anime {
    background: #3a2820;
    border-color: rgba(255, 132, 101, 0.35);
}

/* --- Mobile: 1 colonna --- */
@media (max-width: 700px) {
    .form-section {
        padding: 18px 0;
    }
    .form-section-head {
        margin-bottom: 16px;
    }
    .form-section-label {
        font-size: 16px;
    }
    .form-section-body {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .form-section-icon {
        width: 32px;
        height: 32px;
    }
}
/* ============================================================
   v63 — Fix larghezza card in griglia/saghe (dopo overflow:visible)
   ============================================================ */

.titles-list.view-grid .title-item,
.titles-list.view-sagas .title-item {
    min-width: 0;
    max-width: 100%;
}
/* ============================================================
   v64 — Vista compatta su mobile: card schiacciate su 1 riga
   ============================================================ */
@media (max-width: 700px) {

    /* La card diventa una riga bassa */
    .titles-list.view-compact .title-item {
        padding: 8px 12px;
        gap: 8px;
        align-items: center;
    }

    /* .title-info resta ORIZZONTALE (era column) */
    .titles-list.view-compact .title-info {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    /* Titolo + tipo: prendono spazio, si restringono */
    .titles-list.view-compact .title-main {
        flex: 1 1 auto;
        min-width: 0;
        gap: 6px;
        flex-wrap: nowrap;
    }

    /* Rimuovi il limite di 340px su mobile: qui serve flessibile */
    .titles-list.view-compact .title-main > .title-link,
    .titles-list.view-compact .title-main > strong {
        max-width: none;
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Anno + voto: compatti, non si allargano */
    .titles-list.view-compact .title-meta {
        flex: 0 0 auto;
        gap: 8px;
        align-items: center;
        white-space: nowrap;
    }

    /* Nascondi il GENERE (è sempre il 2° meta-item dentro .title-meta) */
    .titles-list.view-compact .title-meta .meta-item:nth-child(2) {
        display: none;
    }

    /* Dimensione ridotta per i testi */
    .titles-list.view-compact .title-main strong {
        font-size: 13px;
    }
    .titles-list.view-compact .type-pill {
        font-size: 9px;
        padding: 3px 6px;
    }
    .titles-list.view-compact .meta-item {
        font-size: 11px;
    }
    .titles-list.view-compact .rating-badge {
        font-size: 13px;
    }

    /* Pulsanti più piccoli, allineati in riga */
    .titles-list.view-compact .title-footer {
        gap: 4px;
        flex: 0 0 auto;
        margin: 0;
        padding: 0;
    }
    .titles-list.view-compact .icon-btn {
        width: 34px;
        height: 34px;
    }
    .titles-list.view-compact .icon-btn svg {
        width: 14px;
        height: 14px;
    }
        /* Nascondi anche il conteggio rewatch */
    .titles-list.view-compact .title-rewatch {
        display: none;
    }
}
/* ============================================================
   v65 — Calendario modale custom
   ============================================================ */
.calendar-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: grid;
    place-items: center;
    background: rgba(20, 22, 26, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    padding: 20px;
    transition: opacity 250ms ease;
}
.calendar-overlay.open {
    opacity: 1;
}
.calendar-overlay[hidden] {
    display: none !important;
}

.calendar-box {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
    padding: 48px 22px 22px;
    transform: scale(0.94);
    transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
}
.calendar-overlay.open .calendar-box {
    transform: scale(1);
}

.calendar-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.calendar-close:hover {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: #f0c4b6;
}

.calendar-header {
    display: grid;
    grid-template-columns: 36px 1fr 36px;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.calendar-month {
    font-family: "Playfair Display", serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
    text-align: center;
}
.calendar-nav {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--muted);
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.calendar-nav:hover {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: #f0c4b6;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 0 2px;
    margin-bottom: 4px;
}
.calendar-weekdays span {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 6px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 0 2px;
    margin-bottom: 14px;
    /* 6 righe × 44px + 5 gap × 2px = 274px: fissa l'altezza così la
       freccia non si sposta quando un mese ha 5 righe invece di 6 */
    min-height: 274px;
}
.calendar-cell {
    display: grid;
    place-items: center;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 9px;
    color: var(--ink);
    font: 500 14px "DM Sans", sans-serif;
    cursor: pointer;
    transition: background 130ms ease, color 130ms ease, transform 130ms ease;
}
.calendar-cell:hover:not(.calendar-cell-disabled):not(.calendar-cell-empty) {
    background: var(--soft-orange);
    color: var(--accent);
}
.calendar-cell-empty {
    pointer-events: none;
    cursor: default;
}
.calendar-cell-today {
    font-weight: 700;
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.calendar-cell-selected {
    background: var(--accent);
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(233, 111, 77, 0.35);
}
.calendar-cell-selected:hover {
    background: var(--accent-dark);
    color: white;
}
.calendar-cell-disabled {
    color: #c4c2b9;
    cursor: not-allowed;
    opacity: 0.4;
}

.calendar-today {
    display: block;
    width: 100%;
    height: 42px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    font: 700 13px "DM Sans", sans-serif;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.calendar-today:hover {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: #f0c4b6;
}

/* Dark */
[data-theme="dark"] .calendar-overlay {
    background: rgba(0, 0, 0, 0.7);
}
[data-theme="dark"] .calendar-cell-disabled {
    color: #4a4f56;
}
[data-theme="dark"] .calendar-close:hover,
[data-theme="dark"] .calendar-nav:hover,
[data-theme="dark"] .calendar-today:hover {
    background: var(--soft-orange);
    color: var(--accent);
    border-color: rgba(255, 132, 101, 0.35);
}

/* Mobile */
@media (max-width: 700px) {
    .calendar-box {
        padding: 42px 14px 14px;
    }
    .calendar-cell {
        height: 44px;
        font-size: 15px;
    }
}
/* --- Trigger campo data (bottone al posto dell'input nativo) --- */
.date-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    height: 46px;
    padding: 0 14px;
    background: #fbfbfa;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink);
    font: 500 13px "DM Sans", sans-serif;
    cursor: pointer;
    text-align: left;
    transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}
.date-trigger:hover {
    background: white;
    border-color: #d5d5d0;
}
.date-trigger:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, 0.13);
}
.date-trigger-placeholder {
    color: #a7abb0;
}
.date-trigger-icon {
    color: var(--muted);
    flex-shrink: 0;
}
[data-theme="dark"] .date-trigger {
    background: #262a30;
}
[data-theme="dark"] .date-trigger:hover {
    background: #2a2e35;
    border-color: #3a3f46;
}
[data-theme="dark"] .date-trigger-placeholder {
    color: #6a7079;
}
/* Fix: la modale watched-date usa .date-trigger al posto dell'input */
.watched-date-field .date-trigger {
    margin: 0;
}
/* ============================================================
   v66 — Form aggiunta compatto (desktop) + modale pre-aggiunta
   ============================================================ */

/* ---------- Desktop (>= 1024px): riga unica compatta ---------- */
@media (min-width: 1024px) {
    .title-form {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-end;
        gap: 10px;
        max-width: none;
    }
    .title-form > .field-title {
        flex: 1 1 auto;
        min-width: 0;
    }
    .title-form > .details-form-btn {
        flex: 0 0 auto;
        width: auto;
        height: 46px;
    }
    .title-form > .form-actions {
        display: flex;
        gap: 8px;
        flex: 0 0 auto;
    }
    .title-form > .form-actions > .primary-button,
    .title-form > .form-actions > .clear-form-btn {
        width: auto;
        height: 46px;
    }

    /* Stato e Voto vivono solo nella modale su desktop */
    .title-form > .state-field,
    .title-form > .rating-field {
        display: none !important;
    }
}

/* ---------- Tablet/mobile (< 1024px): comportamento invariato ----------
   `.form-actions` con `display: contents` non genera una scatola,
   quindi Aggiungi e Svuota tornano ad essere item diretti del form.
   Le regole v39 (tablet) e v40 (mobile) continuano a funzionare. */
@media (max-width: 1023px) {
    .title-form > .form-actions {
        display: contents;
    }
}

/* Tablet: stessi path vecchi, ma i bottoni ora stanno dentro .form-actions
   (con display:contents → diventano item grid del .title-form) */
@media (min-width: 701px) and (max-width: 1023px) {
    .title-form > .form-actions > .primary-button { grid-area: add; }
    .title-form > .form-actions > .clear-form-btn { grid-area: clear; }

    .title-form > .form-actions > .primary-button,
    .title-form > .form-actions > .clear-form-btn {
        width: 100%;
        height: 46px;
        padding: 0 24px;
        font-size: 14px;
        border-radius: 9px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile: rifai l'ordine per i nuovi path (i vecchi `.title-form > .primary-button` non combaciano più) */
@media (max-width: 700px) {
    .title-form > .form-actions > .primary-button { order: 5; width: 100%; }
    .title-form > .form-actions > .clear-form-btn { order: 6; width: 100%; }
    /* Se .form-actions fosse visibile, i figli devono essere full-width */
    .title-form > .form-actions > * { width: 100%; }
}

/* Il pulsante "Svuota" deve restare invisibile finché non si seleziona un titolo */
.clear-form-btn[hidden] {
    display: none !important;
}

/* ---------- Nuova modale pre-aggiunta (#add-modal) ---------- */
.modal-field {
    text-align: left;
    margin-bottom: 18px;
}
.modal-field > label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}
.modal-field > label span {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: var(--muted);
}
.modal-field .state-pills {
    height: 46px;
}
.modal-field .rating-input {
    max-width: 220px;
    margin: 0 auto;
}
.modal-field .date-trigger {
    max-width: 280px;
    margin: 0 auto;
}
.modal-field[hidden] {
    display: none !important;
}
/* ============================================================
   v67 — Campo titolo compatto che si adatta al contenuto
   ============================================================ */

@media (min-width: 1024px) {
    /* Sovrascrive il flex: 1 1 auto di v66: niente più campo "gonfio" */
    .title-form > .field-title {
        flex: 0 0 auto;
        width: 280px;              /* larghezza base */
        min-width: 220px;
        max-width: 520px;
        transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1);
    }
    .title-form > .field-title > input {
        width: 100%;
    }
}

/* Nessun impatto su tablet/mobile: le regole vivono solo nel @media desktop */

/* ============================================================
   v68 — Pulsante "Apri su TMDB" nella pagina di dettaglio
   ============================================================ */
.detail-share-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.detail-tmdb-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 11px;
    font: 700 13px "DM Sans", sans-serif;
    text-decoration: none;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition:
        background var(--dur-fast) ease,
        transform var(--dur-base) var(--ease-smooth);
}
.detail-tmdb-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    transform: translateY(-1px);
}
.detail-tmdb-btn svg { flex-shrink: 0; }

@media (max-width: 700px) {
    .detail-tmdb-btn {
        width: 100%;
        justify-content: center;
    }
}
/* ============================================================
   v69 — Menu "Condividi" a tendina
   ============================================================ */
.share-menu-wrap {
    position: relative;
    display: inline-flex;
}

.detail-share-btn[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.28);
}

.share-menu {
    position: fixed;
    min-width: 220px;
    padding: 5px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 11px;
    box-shadow: 0 14px 36px rgba(39, 44, 50, 0.20);
    z-index: 200;
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top left;
    pointer-events: none;
    transition:
        opacity 180ms ease,
        transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.share-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.share-menu[hidden] {
    display: none !important;
}

.share-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 7px;
    font: 500 13px "DM Sans", sans-serif;
    text-align: left;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}
.share-menu-item:hover {
    background: var(--soft-orange);
    color: var(--accent);
}
.share-menu-item svg {
    flex-shrink: 0;
    color: var(--muted);
    transition: color 150ms ease;
}
.share-menu-item:hover svg {
    color: var(--accent);
}

[data-theme="dark"] .share-menu {
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}

@media (max-width: 700px) {
    .share-menu-wrap { width: 100%; }
    .share-menu {
        min-width: 0;
        width: auto;      /* left/right li setta il JS */
    }
}
/* ============================================================
   v70 — Stato "Generando" del pulsante Condividi
   ============================================================ */
.detail-share-btn.loading {
    cursor: wait;
    opacity: 0.85;
}
/* ============================================================
   v71 — Scopri: header, espansione in-page, filtri
   ============================================================ */

/* ---------- Header con "Vedi tutti" ---------- */
.discover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 0.9rem;
    padding: 0 0.2rem;
}
.discover-header .discover-title {
    margin: 0;
    padding: 0;
}

.discover-see-all {
    flex-shrink: 0;
    padding: 6px 12px;
    background: transparent;
    color: #ff7a59;
    border: 1px solid rgba(255, 122, 89, 0.4);
    border-radius: 9px;
    font: 600 0.82rem "DM Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease,
        transform 0.12s ease;
}
.discover-see-all:hover {
    background: rgba(255, 122, 89, 0.12);
    border-color: #ff7a59;
}
.discover-see-all:active {
    transform: scale(0.96);
}

/* ---------- Sezione espansa / nascosta ---------- */
.discover-section.hidden-by-expand {
    display: none;
}

.discover-section.expanded {
    margin: 1.6rem 0;
    background: rgba(128, 128, 128, 0.04);
}

.discover-section.expanded .discover-see-all {
    display: none;
}

/* ---------- Controlli espansi (Torna + filtri) ---------- */
.discover-expanded-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 0 0.2rem 1rem 0.2rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.14);
    margin-bottom: 1rem;
}
.discover-expanded-controls[hidden] {
    display: none !important;
}

.discover-back-btn {
    padding: 6px 12px;
    background: transparent;
    color: inherit;
    border: 1px solid rgba(128, 128, 128, 0.28);
    border-radius: 9px;
    font: 600 0.82rem "DM Sans", sans-serif;
    cursor: pointer;
    opacity: 0.85;
    white-space: nowrap;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        opacity 0.18s ease,
        transform 0.12s ease;
}
.discover-back-btn:hover {
    background: rgba(128, 128, 128, 0.10);
    border-color: rgba(128, 128, 128, 0.5);
    opacity: 1;
}
.discover-back-btn:active {
    transform: scale(0.96);
}

/* ---------- Filtri (Tutti / Film / Serie TV) ---------- */
.discover-filters {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: rgba(128, 128, 128, 0.10);
    border-radius: 10px;
}
.discover-filter {
    padding: 6px 12px;
    background: transparent;
    border: 0;
    border-radius: 7px;
    color: inherit;
    opacity: 0.65;
    font: 600 0.82rem "DM Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 0.18s ease,
        opacity 0.18s ease,
        color 0.18s ease;
}
.discover-filter:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.06);
}
.discover-filter.active {
    opacity: 1;
    background: #ff7a59;
    color: #fff;
}

/* ---------- Griglia in espanso ---------- */
.discover-section.expanded .discover-scroll-wrap {
    display: block;
}

.discover-section.expanded .discover-scroll {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1.1rem;
    overflow: visible;
    padding: 0.3rem 0.2rem 1rem 0.2rem;
    scroll-snap-type: none;
}

.discover-section.expanded .discover-card {
    width: auto;
    flex: none;
}

.discover-section.expanded .discover-poster {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
}

/* Le frecce non servono più in espanso */
.discover-section.expanded .discover-arrow {
    display: none;
}

/* ---------- "Nessun risultato" ---------- */
.discover-no-results[hidden] {
    display: none !important;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    .discover-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .discover-see-all {
        font-size: 0.78rem;
        padding: 5px 10px;
    }
    .discover-expanded-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .discover-back-btn {
        width: 100%;
        text-align: center;
    }
    .discover-filters {
        display: flex;
        justify-content: center;
        width: 100%;
    }
    .discover-filter {
        flex: 1;
        text-align: center;
    }
    .discover-section.expanded .discover-scroll {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.9rem;
    }
}

/* ---------- Dark mode: accenti coerenti ---------- */
[data-theme="dark"] .discover-back-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.3);
}
[data-theme="dark"] .discover-filter:hover {
    background: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .discover-expanded-controls {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
/* ============================================================
   Discover search (Parte B)
   ============================================================ */
.discover-search-wrap {
    max-width: 720px;
    margin: 0 auto 24px;
    padding: 0 1rem;
}
.discover-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.discover-search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 111, 77, 0.15), var(--shadow);
}
.discover-search-bar > svg {
    color: var(--muted);
    flex-shrink: 0;
}
.discover-search-input {
    flex: 1;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent !important;
    background-image: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none;
    color: inherit;
    font: 500 0.95rem "DM Sans", sans-serif;
    padding: 4px 0;
}
.discover-search-input:focus,
.discover-search-input:focus-visible {
    background: transparent !important;
    border: 0 !important;
    border-color: transparent !important;
    box-shadow: none !important;
    outline: none;
}
.discover-search-input::-webkit-search-decoration,
.discover-search-input::-webkit-search-results-button,
.discover-search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
}
.discover-search-clear {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 0;
    background: rgba(128, 128, 128, 0.12);
    color: inherit;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, transform 0.12s ease;
}
.discover-search-clear:hover {
    background: rgba(128, 128, 128, 0.22);
}
.discover-search-clear:active {
    transform: scale(0.92);
}

/* Contenitore risultati */
.discover-search-results {
    max-width: 1100px;
    margin: 0 auto 40px;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.discover-search-results > .discover-back-btn {
    align-self: flex-start;
}
.discover-search-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.discover-search-heading {
    font: 600 1.1rem "DM Sans", sans-serif;
    margin: 0;
    color: inherit;
    letter-spacing: -0.01em;
}

/* Card titolo */
.discover-search-titles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

/* Card persona */
.discover-search-persons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.discover-person-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.discover-person-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.discover-person-avatar {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}
.discover-person-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.discover-person-initial {
    font: 600 1.1rem "DM Sans", sans-serif;
    color: var(--muted);
}
.discover-person-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.discover-person-name {
    font: 600 0.9rem "DM Sans", sans-serif;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.discover-person-role {
    font: 500 0.72rem "DM Sans", sans-serif;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Dark mode */
[data-theme="dark"] .discover-search-bar {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .discover-search-bar:focus-within {
    border-color: var(--accent);
}
[data-theme="dark"] .discover-search-clear {
    background: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .discover-search-clear:hover {
    background: rgba(255, 255, 255, 0.18);
}
[data-theme="dark"] .discover-person-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .discover-person-card:hover {
    border-color: var(--accent);
}
[data-theme="dark"] .discover-person-avatar {
    background: rgba(255, 255, 255, 0.08);
}

/* Mobile */
@media (max-width: 600px) {
    .discover-search-wrap {
        padding: 0 0.75rem;
        margin-bottom: 18px;
    }
    .discover-search-bar {
        padding: 8px 12px;
    }
    .discover-search-results {
        padding: 0 0.75rem;
    }
    .discover-search-titles {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .discover-search-persons {
        grid-template-columns: 1fr;
    }
}
/* ---------- Discover: vista persona ---------- */
.discover-person-view {
    max-width: 1100px;
    margin: 0 auto 40px;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.discover-person-view > .discover-back-btn {
    align-self: flex-start;
}
.discover-person-actions {
    display: flex;
    justify-content: center;
    margin-top: 6px;
}
.discover-person-actions .discover-see-all {
    /* riusa lo stile del "Vedi tutti →" delle sezioni */
    padding: 8px 16px;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .discover-person-view {
        padding: 0 0.75rem;
    }
    .discover-person-actions {
        width: 100%;
    }
    .discover-person-actions .discover-see-all {
        width: 100%;
        text-align: center;
    }
}
/* Forza la scomparsa degli elementi nascosti in Discover
   (specificità alta + !important = vince su qualsiasi display: flex) */
#discover-search-results[hidden],
#discover-person-view[hidden],
#search-titles-section[hidden],
#search-persons-section[hidden],
#search-empty[hidden],
#discover-person-empty[hidden],
#discover-person-actions[hidden] {
    display: none !important;
}
/* Filtri nella vista persona: centrati sotto l'heading */
#discover-person-filters {
    justify-content: center;
}
@media (max-width: 600px) {
    #discover-person-filters {
        width: 100%;
    }
}
/* Desktop: centra il blocco titolo + pulsanti nella card */
@media (min-width: 1024px) {
    .title-form {
        justify-content: center;
    }
}
@media (min-width: 1024px) {
    .add-panel > .form-card {
        width: fit-content;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    .add-panel.open {
        display: flex;
        justify-content: center;
    }
}
/* ---------- Calendario: navigazione mese/anno ---------- */
.calendar-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.calendar-title-month,
.calendar-title-year {
    background: transparent;
    border: 0;
    padding: 4px 8px;
    border-radius: 8px;
    color: var(--ink);
    font: 600 1rem "DM Sans", sans-serif;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}
.calendar-title-month:hover,
.calendar-title-year:hover {
    background: var(--soft-orange);
    color: var(--accent);
}
.calendar-title-range {
    font: 600 1rem "DM Sans", sans-serif;
    letter-spacing: 0.01em;
    color: var(--ink);
}

.calendar-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
    /* stessa altezza della vista giorni, così il box non salta */
    min-height: 274px;
    align-content: start;
}
.calendar-picker-btn {
    height: 48px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 10px;
    color: var(--ink);
    font: 600 0.9rem "DM Sans", sans-serif;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.calendar-picker-btn:hover {
    background: var(--soft-orange);
    color: var(--accent);
}
.calendar-picker-btn.selected {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 10px rgba(233, 111, 77, 0.35);
}
.calendar-picker-btn.selected:hover {
    background: var(--accent-dark);
    color: white;
}

[data-theme="dark"] .calendar-title-month:hover,
[data-theme="dark"] .calendar-title-year:hover,
[data-theme="dark"] .calendar-picker-btn:hover {
    background: var(--soft-orange);
    color: var(--accent);
}
/* ============================================================
   Edit — versione compatta
   ============================================================ */
.edit-card {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
}
.edit-card.form-card {
    padding: 24px 28px 26px;
}
.edit-card .section-heading {
    margin-bottom: 14px;
}
.edit-card .form-section {
    padding: 18px 0;
}
.edit-card .form-section:first-of-type {
    padding-top: 4px;
    border-top: 0;
}
.edit-card .form-section-head {
    gap: 12px;
    margin-bottom: 14px;
}
.edit-card .form-section-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}
.edit-card .form-section-label {
    font-size: 16px;
}
.edit-card .form-section-body {
    gap: 12px 16px;
}
.edit-card .form-buttons {
    margin-top: 18px;
    padding-top: 16px;
}

/* Identità: Tipo + Anno + Genere su 3 colonne */
.form-section-identity .form-section-body {
    grid-template-columns: repeat(3, 1fr);
}

/* Visione: Stato full-width, Voto + Rivisto in 2 colonne, Data full */
.form-section:not(.form-section-identity) .rewatch-field {
    max-width: 220px;
}

@media (max-width: 700px) {
    .edit-card.form-card {
        padding: 20px 18px 22px;
    }
    .form-section-identity .form-section-body {
        grid-template-columns: 1fr;
    }
}
/* ---------- Sezione Note collassabile ---------- */
.form-section-head-toggle {
    width: 100%;
    background: transparent;
    border: 0;
    padding: 0;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.form-section-head-toggle .form-section-head-text {
    flex: 1;
    min-width: 0;
}
.form-section-chevron {
    flex-shrink: 0;
    color: var(--muted);
    transition: transform 220ms ease;
}
.form-section-notes.is-open .form-section-chevron {
    transform: rotate(90deg);
}

.form-section-preview {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}
.form-section-notes.is-open .form-section-preview {
    display: none;
}
.form-section-notes:not(.is-open) .form-section-desc {
    display: none;
}
.form-section-notes:not(.is-open) .form-section-head {
    margin-bottom: 0;
}

.form-section-notes .form-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 280ms ease;
}
.form-section-notes.is-open .form-section-body {
    max-height: 400px;
    margin-top: 14px;
}
/* ---------- Edit: backdrop sfocato dietro l'hero ---------- */
.hero-with-backdrop {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    padding-top: 28px;
    padding-bottom: 28px;
}
.hero-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.hero-backdrop img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(10px) saturate(1.3) brightness(0.6);
    transform: scale(1.06);
}
.hero-with-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0) 30%,
        var(--paper) 100%
    );
}
.hero-with-backdrop > *:not(.hero-backdrop) {
    position: relative;
    z-index: 2;
}
.hero-with-backdrop .eyebrow,
.hero-with-backdrop h1,
.hero-with-backdrop .hero-copy {
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
    color: #ffffff;
}
.hero-with-backdrop h1 span {
    /* il colore "pri" resta accent, non lo sovrascriviamo */
    color: var(--accent);
}
.hero-with-backdrop .brand-mark {
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
}

[data-theme="dark"] .hero-backdrop img {
    filter: blur(8px) saturate(1.3) brightness(0.55);
}

@media (max-width: 700px) {
    .hero-with-backdrop {
        padding-top: 20px;
        padding-bottom: 20px;
        border-radius: 12px;
    }
    .hero-backdrop img {
        filter: blur(35px) saturate(1.4) brightness(0.5);
    }
}
/* =============================================
   Bottom sheet azioni card (solo mobile)
   ============================================= */
.card-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.card-sheet-overlay.open { opacity: 1; }

/* Regola di progetto: contenitori flex/grid con [hidden] */
#card-sheet[hidden] { display: none !important; }

.card-sheet {
    width: 100%;
    max-width: 480px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    background: var(--card-bg, #1c1c1e);
    color: var(--text-color, #fff);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    transform: translateY(100%);
    transition: transform .25s ease;
}

.card-sheet-overlay.open .card-sheet { transform: translateY(0); }

.card-sheet-title {
    margin: 0 0 8px;
    padding: 6px 12px 10px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.6;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card-sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 16px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease;
}

.card-sheet-item:hover,
.card-sheet-item:active {
    background: rgba(255, 255, 255, 0.08);
}

.card-sheet-item-danger { color: #ff453a; }

.card-sheet-cancel {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 14px 16px;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 12px 12px;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* Mobile-only: su desktop il foglio non deve MAI aprirsi.
   Il JS controlla già via matchMedia, questa è una rete di sicurezza. */
@media (min-width: 1024px) {
    .card-sheet-overlay { display: none !important; }
}
/* =============================================
   Mobile: nascondi il cestino separato sulla card.
   L'eliminazione passa dal bottom sheet.
   ============================================= */
@media (max-width: 1023px) {
    .title-footer .delete-form { display: none !important; }
}
/* ============================================================
   v72 — Menu "⋯" ancorato all'item (poster o riga compact)
   ============================================================ */

/* L'item è il contenitore di riferimento per il wrap */
.titles-list .title-item { position: relative; }

/* Il wrap: in grid/sagas è assoluto in alto a sx del poster */
.titles-list .title-item > .title-menu-wrap {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
    display: inline-flex;
}

/* Pillola circolare scura (viste con poster: grid, sagas) */
.titles-list .title-item .icon-btn-menu {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    transition: background .15s ease, border-color .15s ease;
}
.titles-list .title-item .icon-btn-menu svg {
    width: 12px;
    height: 12px;
}

/* Hover / focus / aperto */
.titles-list .title-item .icon-btn-menu:hover,
.titles-list .title-item .icon-btn-menu:focus-visible {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.4);
}
.titles-list .title-item:hover .icon-btn-menu {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.4);
}
.titles-list .title-item .icon-btn-menu[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.95);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Dropdown: si apre verso destra/basso */
.title-item .title-menu {
    bottom: auto;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    transform-origin: top left;
    transform: translateY(-8px) scale(0.96);
}
.title-item .title-menu.open {
    transform: translateY(0) scale(1);
}

/* Voce "Elimina" nel dropdown: rossa */
.title-menu-item-danger { color: #d9482b; }
.title-menu-item-danger:hover { background: rgba(217, 72, 43, 0.08); }
[data-theme="dark"] .title-menu-item-danger { color: #ff7a5c; }

/* Il footer non ha più nulla da mostrare */
.title-footer { display: none !important; }

/* ============================================
   Vista COMPACT: il wrap è inline, a fine riga
   ============================================ */
.titles-list.view-compact .title-item > .title-menu-wrap {
    position: relative;      /* ← ancora il menu al bottone, non alla card */
    margin-left: auto;
    flex-shrink: 0;
    order: 99;
    display: inline-flex;
    align-items: center;
}

.titles-list.view-compact .title-item .icon-btn-menu {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--muted);
    transition: background .15s ease, color .15s ease;
}
.titles-list.view-compact .title-item .icon-btn-menu svg {
    width: 15px;
    height: 15px;
}
.titles-list.view-compact .title-item .icon-btn-menu:hover,
.titles-list.view-compact .title-item .icon-btn-menu:focus-visible {
    background: rgba(0, 0, 0, 0.06);
    color: var(--ink);
}
[data-theme="dark"] .titles-list.view-compact .title-item .icon-btn-menu:hover,
[data-theme="dark"] .titles-list.view-compact .title-item .icon-btn-menu:focus-visible {
    background: rgba(255, 255, 255, 0.08);
}

/* Nella compact il menu si apre a destra del bottone (allineato al bordo destro) */
.titles-list.view-compact .title-item .title-menu {
    left: auto;
    right: 0;
    top: calc(100% + 6px);
    transform-origin: top right;
    transform: translateY(-6px) scale(0.96);
}
.titles-list.view-compact .title-item .title-menu.open {
    transform: translateY(0) scale(1);
}

/* ALZA l'item sopra gli altri quando un menu è aperto.
   Serve perché .title-item ha transform: translate3d(...), che crea
   uno stacking context indipendente → il menu resta sotto le card
   successive. :has() rileva il menu aperto e alza l'item. */
.titles-list .title-item:has(.title-menu.open) {
    z-index: 10;
}
/* ============================================================
   v0.38.x — User-menu (avatar hover/tap) + Home in user-bar
   ============================================================ */

/* Wrapper dell'avatar + menu */
.user-menu-wrap {
    position: relative;
}

/* Dropdown menu */
.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    padding: 6px;
    background: var(--card, #fff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px) scale(0.97);
    transform-origin: top right;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 200;
}

.user-menu-wrap:hover .user-menu,
.user-menu-wrap:focus-within .user-menu,
.user-menu-wrap.menu-open .user-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Item */
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-menu-item:hover {
    background: rgba(128, 128, 128, 0.1);
}

.user-menu-item-danger {
    color: #e35d6a;
}

.user-menu-item-danger:hover {
    background: rgba(227, 93, 106, 0.1);
}

.user-menu-form {
    margin: 0;
    padding: 0;
    border: 0;
}

/* Dark mode */
[data-theme="dark"] .user-menu {
    background: #23262b;
    border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .user-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Mobile/tablet: niente hover, si apre con tap */
@media (max-width: 1023px) {
    .user-menu-wrap:hover .user-menu {
        opacity: 0;
        visibility: hidden;
        transform: translateY(-4px) scale(0.97);
    }
    .user-menu-wrap.menu-open .user-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
    }
}
/* --- Colori specifici delle voci del menu utente --- */
.user-menu-item-profile {
    color: #d98971;      /* arancione dell'app (#ff7a59) desaturato */
}
.user-menu-item-profile:hover {
    background: rgba(255, 122, 89, 0.1);
    color: #ff7a59;
}

.user-menu-item-watchlist {
    color: #107bde;      /* blu del pulsante "Da vedere" nel profilo */
}
.user-menu-item-watchlist:hover {
    background: rgba(16, 123, 222, 0.1);
    color: #107bde;
}

/* Dark mode: tonalità più chiare per contrasto su sfondo scuro */
[data-theme="dark"] .user-menu-item-profile {
    color: #e8a992;
}
[data-theme="dark"] .user-menu-item-profile:hover {
    background: rgba(255, 122, 89, 0.14);
    color: #ff9478;
}
[data-theme="dark"] .user-menu-item-watchlist {
    color: #4aa8f0;
}
[data-theme="dark"] .user-menu-item-watchlist:hover {
    background: rgba(74, 168, 240, 0.14);
    color: #6bb8f5;
}
/* ============================================================
   v0.39.x — Pagina Modifica: sezione Identità in modalità lettura
   ============================================================ */

.identity-readonly {
    grid-column: 1 / -1;
    padding: 4px 0 0;
}

.identity-readonly-title {
    font-family: "Playfair Display", serif;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin: 0 0 8px;
    line-height: 1.15;
}

.identity-readonly-meta {
    font-family: "DM Sans", sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

.identity-dot {
    margin: 0 6px;
    opacity: 0.5;
}

.identity-readonly-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 10px 0 0;
    padding: 4px 10px;
    font-family: "DM Sans", sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: #ff7a59;
    background: rgba(255, 122, 89, 0.1);
    border-radius: 999px;
    line-height: 1;
}

/* Dark mode */
[data-theme="dark"] .identity-readonly-title { color: var(--ink); }
[data-theme="dark"] .identity-readonly-meta { color: #9ba1ab; }
[data-theme="dark"] .identity-readonly-hint {
    color: #ff9478;
    background: rgba(255, 122, 89, 0.16);
}

/* Mobile: rimpicciolisci un attimo */
@media (max-width: 700px) {
    .identity-readonly-title { font-size: 1.4rem; }
    .identity-readonly-meta { font-size: 0.88rem; }
}
/* ============================================================
   v0.39.x — Sezione Visione: voto in evidenza
   ============================================================ */

.vision-body {
    display: flex !important;
    flex-direction: column;
    gap: 18px;
}

.vision-rating-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 20px;
    background: linear-gradient(180deg, rgba(255, 122, 89, 0.08) 0%, rgba(255, 122, 89, 0.03) 100%);
    border: 1px solid rgba(255, 122, 89, 0.18);
    border-radius: 16px;
}

.vision-rating-label {
    margin: 0;
    font-family: "DM Sans", sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #ff7a59;
}

.vision-rating-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.vision-rating-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 122, 89, 0.35);
    background: rgba(255, 255, 255, 0.65);
    color: #ff7a59;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    line-height: 1;
    padding: 0;
}

.vision-rating-btn:hover {
    background: #ff7a59;
    color: #fff;
    box-shadow: 0 4px 14px rgba(255, 122, 89, 0.3);
}

.vision-rating-btn:active {
    transform: scale(0.94);
}

.vision-rating-input {
    width: 110px;
    border: 0;
    background: transparent;
    text-align: center;
    font-family: "Playfair Display", serif;
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    padding: 0;
    outline: none;
}

.vision-rating-input::placeholder {
    color: rgba(128, 128, 128, 0.5);
}

.vision-divider {
    height: 1px;
    background: var(--line);
    margin: 4px 0 2px;
    border: 0;
}

/* Rewatch: era limitato a 220px, ora è full-width ma più stretto */
.vision-body .rewatch-field {
    max-width: 280px;
}

/* Dark mode */
[data-theme="dark"] .vision-rating-hero {
    background: linear-gradient(180deg, rgba(255, 122, 89, 0.1) 0%, rgba(255, 122, 89, 0.04) 100%);
    border-color: rgba(255, 122, 89, 0.22);
}
[data-theme="dark"] .vision-rating-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 122, 89, 0.4);
    color: #ff9478;
}
[data-theme="dark"] .vision-rating-btn:hover {
    background: #ff7a59;
    color: #fff;
}

/* Mobile */
@media (max-width: 700px) {
    .vision-rating-hero {
        padding: 18px 14px 16px;
    }
    .vision-rating-input {
        width: 90px;
        font-size: 2.2rem;
    }
    .vision-rating-btn {
        width: 38px;
        height: 38px;
        font-size: 1.15rem;
    }
}
/* ============================================================
   v0.39.x — Fix layout sezione Visione
   ============================================================ */

/* Il body della Visione: forza colonna, allineamento a sinistra */
.form-section-body.vision-body {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 14px !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    flex-wrap: nowrap !important;
}

/* Il box del voto: centrato, ma compatto */
.form-section-body.vision-body .vision-rating-hero {
    width: 100%;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
    padding: 14px 16px 14px;
    gap: 6px;
}

.form-section-body.vision-body .vision-rating-input {
    width: 86px;
    font-size: 2rem;
}

.form-section-body.vision-body .vision-rating-btn {
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
}

.form-section-body.vision-body .vision-rating-label {
    font-size: 0.66rem;
    letter-spacing: 0.12em;
}

/* Separatore full-width anche visivamente */
.form-section-body.vision-body .vision-divider {
    width: 100%;
    margin: 2px 0 0;
}

/* Gli altri campi occupano tutta la larghezza disponibile */
.form-section-body.vision-body .state-field,
.form-section-body.vision-body .rewatch-field {
    max-width: none;
    width: 100%;
}

/* Stato: le due pill restano larghe full */
.form-section-body.vision-body .state-pills {
    max-width: none;
    width: 100%;
}

/* Rivisto: stepper non enorme */
.form-section-body.vision-body .rewatch-field .rating-input {
    max-width: 220px;
}

/* Mobile */
@media (max-width: 700px) {
    .form-section-body.vision-body .vision-rating-hero {
        max-width: none;
        padding: 12px 14px;
    }
    .form-section-body.vision-body .vision-rating-input {
        width: 76px;
        font-size: 1.85rem;
    }
    .form-section-body.vision-body .vision-rating-btn {
        width: 32px;
        height: 32px;
    }
}
/* ============================================================
   v0.39.x — Larghezze compatte nella sezione Visione
   ============================================================ */

/* Stato: le pill non occupano tutta la larghezza */
.form-section-body.vision-body .state-pills {
    max-width: 380px;
}

/* Data di visione: trigger più stretto */
.form-section-body.vision-body .date-trigger {
    max-width: 260px;
}

/* Rivisto: stepper contenuto */
.form-section-body.vision-body .rewatch-field {
    max-width: 220px;
}

/* Mobile: torna full-width, sono più comodi */
@media (max-width: 700px) {
    .form-section-body.vision-body .state-pills,
    .form-section-body.vision-body .date-trigger,
    .form-section-body.vision-body .rewatch-field {
        max-width: none;
    }
}
/* ============================================================
   v0.39.x — Visione: campi centrati
   ============================================================ */

.form-section-body.vision-body .state-field,
.form-section-body.vision-body .state-pills,
.form-section-body.vision-body .vision-watched-meta .field {
    margin-left: auto;
    margin-right: auto;
}

.form-section-body.vision-body .state-pills {
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

.form-section-body.vision-body .date-trigger {
    max-width: 260px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
}

.form-section-body.vision-body .rewatch-field {
    max-width: 220px;
    margin-left: auto;
    margin-right: auto;
}

/* Etichette centrate sopra i controlli */
.form-section-body.vision-body .vision-watched-meta .field label,
.form-section-body.vision-body .state-field > label {
    display: block;
    text-align: center;
}

/* Il wrapper dei meta (data + rivisto) */
.form-section-body.vision-body .vision-watched-meta {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

@media (max-width: 700px) {
    .form-section-body.vision-body .state-pills,
    .form-section-body.vision-body .date-trigger,
    .form-section-body.vision-body .rewatch-field {
        max-width: none;
    }
}
/* ============================================================
   v0.39.x — Identità: poster a sinistra + testo a destra
   ============================================================ */

.identity-readonly {
    display: flex !important;
    align-items: flex-start;
    gap: 18px;
    grid-column: 1 / -1;
    padding: 4px 0 0;
}

.identity-readonly-poster {
    flex-shrink: 0;
    width: 90px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    background: rgba(128, 128, 128, 0.12);
}

.identity-readonly-poster img {
    display: block;
    width: 100%;
    height: auto;
}

.identity-readonly-text {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

/* Bottone "Dettagli" accanto al titolo in edit (v0.48.0) */
.identity-detail-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 107, 53, 0.12);
    color: #ff6b35;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: background 0.18s ease, transform 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}
.identity-detail-btn:hover {
    background: rgba(255, 107, 53, 0.2);
}
.identity-detail-btn:active {
    transform: scale(0.97);
}
.identity-detail-btn svg {
    flex-shrink: 0;
}
[data-theme="dark"] .identity-detail-btn {
    background: rgba(255, 107, 53, 0.18);
}
[data-theme="dark"] .identity-detail-btn:hover {
    background: rgba(255, 107, 53, 0.28);
}

/* Dark mode */
[data-theme="dark"] .identity-readonly-poster {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* Mobile */
@media (max-width: 700px) {
    .identity-readonly {
        gap: 14px;
    }
    .identity-readonly-poster {
        width: 72px;
    }
    .identity-readonly-title {
        font-size: 1.25rem;
    }
}
/* ============================================================
   v0.39.x — Rivisto centrato (tutte le dimensioni)
   ============================================================ */

.form-section-body.vision-body .rewatch-field .rating-input {
    margin-left: auto;
    margin-right: auto;
}
/* ============================================================
   v0.42.0 — Discover: spinner "Carico altri titoli"
   ============================================================ */

.discover-loading {
    margin: 14px 0 0;
    text-align: center;
    font-family: "DM Sans", sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.02em;
    animation: discoverLoadingPulse 1.4s ease-in-out infinite;
}

@keyframes discoverLoadingPulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}
/* ============================================================
   v0.42.x — Badge "in che lista è" nel dettaglio titolo
   ============================================================ */

.detail-list-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: 11px;
    font: 700 14px "DM Sans", sans-serif;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    user-select: none;
    cursor: pointer;
    transition:
        background var(--dur-fast) ease,
        transform var(--dur-base) var(--ease-smooth),
        box-shadow var(--dur-base) var(--ease-smooth);
}

.detail-list-badge-watched {
    background: rgba(255, 122, 89, 0.12);
    color: #ff7a59;
    border-color: rgba(255, 122, 89, 0.28);
    cursor: default;
}

.detail-list-badge-watchlist {
    background: rgba(16, 123, 222, 0.1);
    color: #107bde;
    border-color: rgba(16, 123, 222, 0.28);
}

.detail-list-badge-watchlist:hover {
    background: rgba(16, 123, 222, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(16, 123, 222, 0.25);
}

/* Dark mode */
[data-theme="dark"] .detail-list-badge-watched {
    background: rgba(255, 122, 89, 0.16);
    color: #ff9478;
    border-color: rgba(255, 122, 89, 0.35);
}

[data-theme="dark"] .detail-list-badge-watchlist {
    background: rgba(74, 168, 240, 0.14);
    color: #4aa8f0;
    border-color: rgba(74, 168, 240, 0.32);
}

[data-theme="dark"] .detail-list-badge-watchlist:hover {
    background: rgba(74, 168, 240, 0.22);
    box-shadow: 0 8px 20px rgba(74, 168, 240, 0.25);
}
/* ============================================================
   v0.42.x — Allineamento inline-flex in detail-actions
   ============================================================ */

.detail-actions > .detail-cta,
.detail-actions > .detail-list-badge {
    vertical-align: middle;
}
/* ============================================================
   v0.42.x — Campo generico nelle modali
   ============================================================ */

.modal-field {
    text-align: left;
    margin-top: 16px;
}

.modal-field > label {
    display: block;
    font: 600 12px "DM Sans", sans-serif;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.modal-field > label span {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--muted);
    opacity: 0.75;
}

.modal-field .rating-input {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.modal-field .rating-input input {
    flex: 1;
    text-align: center;
    min-width: 0;
}

/* Il date-trigger nella modale full-width */
.modal-field .date-trigger {
    width: 100%;
}

/* Dark mode coerente */
[data-theme="dark"] .modal-field > label {
    color: #9ba1ab;
}

[data-theme="dark"] .modal-field > label span {
    color: #9ba1ab;
}

/* ---------- v0.46.2 — Mobile: back solo icona ---------- */
@media (max-width: 1023px) {
    .user-bar a.stats-toggle > .stats-icon + span {
        display: none;
    }
    .user-bar a.stats-toggle {
        padding: 8px 12px;
        min-width: 40px;
        justify-content: center;
    }
}
/* ---------- v0.46.2 — Mobile: badge lista sopra il bottone Modifica ---------- */
@media (max-width: 700px) {
    .detail-actions > .detail-list-badge {
        order: -1;
        align-self: center;
        margin-inline: auto;
    }
}
/* ---------- v0.46.2 — Trama espandibile su mobile ---------- */
.overview-toggle {
    display: none;
}

@media (max-width: 700px) {
    .detail-overview {
        display: -webkit-box;
        -webkit-line-clamp: 4;
        line-clamp: 4;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .detail-overview.expanded {
        display: block;
        -webkit-line-clamp: unset;
        line-clamp: unset;
    }
    .overview-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-top: 12px;
        padding: 8px 14px;
        background: transparent;
        color: var(--accent);
        border: 1px solid rgba(233, 111, 77, 0.35);
        border-radius: 999px;
        font: 600 12px "DM Sans", sans-serif;
        cursor: pointer;
        transition: background 0.18s ease, transform 0.12s ease;
    }
    .overview-toggle:hover {
        background: rgba(233, 111, 77, 0.08);
    }
    .overview-toggle:active {
        transform: scale(0.97);
    }
    .overview-toggle svg {
        transition: transform 0.22s ease;
    }
    .overview-toggle[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }
}
/* ---------- v0.47.0 — Chip dei filtri attivi ---------- */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 16px;
}
.active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    background: var(--soft-orange);
    color: var(--accent-dark);
    border: 1px solid rgba(233, 111, 77, 0.28);
    border-radius: 999px;
    font: 600 12px "DM Sans", sans-serif;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.active-filter-chip:hover {
    background: rgba(233, 111, 77, 0.18);
}
.active-filter-chip:active {
    transform: scale(0.97);
}
.active-filter-chip-x {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(233, 111, 77, 0.22);
    font-size: 12px;
    line-height: 1;
}
[data-theme="dark"] .active-filter-chip {
    background: rgba(255, 122, 89, 0.14);
    color: #ff9478;
    border-color: rgba(255, 122, 89, 0.32);
}
[data-theme="dark"] .active-filter-chip:hover {
    background: rgba(255, 122, 89, 0.22);
}
[data-theme="dark"] .active-filter-chip-x {
    background: rgba(255, 122, 89, 0.28);
}
/* ---------- v0.47.0 — Pannello Filtri come bottom sheet (solo mobile) ---------- */
.filters-overlay {
    display: none;
}
.filters-panel-header {
    display: none;
}

@media (max-width: 700px) {
    .filters-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 9998;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        transition: opacity .2s ease;
    }
    .filters-overlay.open { opacity: 1; }
    #filters-overlay[hidden] { display: none !important; }

    .filters-panel,
    .filters-panel.open {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 9999;
        margin-bottom: 0;
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 18px 18px 0 0;
        padding: 6px 18px calc(18px + env(safe-area-inset-bottom, 0px));
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 14px;
        opacity: 1;
        transform: translateY(110%);
        transition: transform .28s cubic-bezier(.22, 1, .36, 1);
    }
    .filters-panel.open {
        transform: translateY(0);
    }
    .filters-panel-header {
        display: grid;
        grid-template-columns: 40px 1fr 40px;
        align-items: center;
        gap: 8px;
        padding: 4px 0 12px;
        border-bottom: 1px solid var(--line);
        margin-bottom: 6px;
    }
    .filters-panel-grabber {
        justify-self: center;
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: rgba(128, 128, 128, 0.45);
    }
    .filters-panel-title {
        text-align: center;
        font: 700 14px "DM Sans", sans-serif;
        color: var(--ink);
    }
    .filters-panel-close {
        justify-self: end;
        width: 32px;
        height: 32px;
        display: inline-grid;
        place-items: center;
        background: transparent;
        border: 0;
        border-radius: 50%;
        color: var(--muted);
        font: 400 22px "DM Sans", sans-serif;
        line-height: 1;
        cursor: pointer;
    }
    .filters-panel-close:hover {
        background: rgba(128, 128, 128, 0.12);
        color: var(--ink);
    }
    /* I campi occupano tutta la larghezza nel bottom sheet */
    .filters-panel .filter-field,
    .filters-panel .filter-field-actor,
    .filters-panel .filters-advanced-panel,
    .filters-panel .filter-checks,
    .filters-panel .filters-reset,
    .filters-panel .filters-advanced-toggle {
        width: 100%;
    }
    .filters-panel .list-sort,
    .filters-panel select,
    .filters-panel input.list-search,
    .filters-panel .actor-search {
        width: 100%;
    }
}
/* ---------- v0.47.0 — Azzera filtri in cima, divider Avanzati, bottom sheet più compatto ---------- */

/* Desktop: Azzera filtri in alto a destra del pannello */
.filters-panel .filters-reset {
    position: absolute;
    top: 14px;
    right: 22px;
    height: 32px;
    padding: 0 14px;
    font-size: 11px;
    z-index: 2;
}

/* Divider sopra "Avanzati" */
.filters-panel .filters-advanced-toggle {
    height: auto;
    padding: 14px 6px 0;
    border-top: 1px solid var(--line);
    margin-top: 6px;
}

@media (max-width: 700px) {
    /* Mobile: Azzera filtri in flow, full-width, sotto l'header */
    .filters-panel .filters-reset {
        position: static;
        width: 100%;
        height: 40px;
        margin: 0 0 4px;
    }
    /* Bottom sheet più compatto */
    .filters-panel {
        gap: 10px;
        padding: 4px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    }
    .filters-panel-header {
        padding: 4px 0 10px;
        margin-bottom: 2px;
    }
    .filters-panel .filters-advanced-toggle {
        margin-top: 2px;
        padding-top: 12px;
    }
    .filters-panel .filters-advanced-panel {
        gap: 12px;
        padding-top: 8px;
    }
}
/* ---------- v0.47.0 — Attore dentro gli Avanzati + Tipo fuori ---------- */

/* Desktop: Attore non più largo di 240px */
@media (min-width: 701px) {
    .filters-advanced-panel .filter-field-actor .actor-filter-wrap {
        max-width: 240px;
    }
}

/* Su mobile Attore resta full-width (già gestito dalla regola esistente a 700px) */

/* Avanzati: checkbox allineate a sinistra, non stirate */
.filters-advanced-panel .filter-checks {
    justify-content: flex-start;
    gap: 12px;
}
/* ---------- v0.47.0 — Checkbox accanto al Tipo ---------- */
.filters-panel > .filter-checks {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
    align-self: end;
    padding-bottom: 1px;
}
/* ---------- v0.47.0 — Riga superiore pannello filtri centrata ---------- */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: center;
    gap: 16px 22px;
    width: 100%;
    flex: 1 1 100%;
}

/* Nessun blocco della riga deve "crescere": sono tutti auto */
.filters-row > .filter-field {
    flex: 0 0 auto;
    min-width: 0;
}
/* Solo "Ordina per" ha un tetto massimo di larghezza */
.filters-row > .filter-field:first-child {
    max-width: 280px;
}
/* Il select "Ordina per" mantiene una larghezza minima decente */
.filters-row > .filter-field:first-child select {
    min-width: 220px;
}

@media (max-width: 700px) {
    .filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .filters-row > .filter-field:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }
}
/* ---------- v0.47.0 — Azzera filtri accanto a "Filtri" ---------- */
.list-controls .filters-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 14px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 10px;
    font: 600 12px "DM Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
    transition:
        background .15s ease,
        color .15s ease,
        border-color .15s ease;
}
.list-controls .filters-reset:hover {
    background: #f5f5f3;
    color: var(--ink);
    border-color: #d5d5d0;
}
[data-theme="dark"] .list-controls .filters-reset:hover {
    background: #262a30;
    color: var(--ink);
}

@media (max-width: 700px) {
    .list-controls .filters-reset {
        width: 100%;
    }
}
/* ---------- v0.47.0 — Pannello filtri stretto, allineato a sinistra ---------- */
@media (min-width: 701px) {
    .filters-panel,
    .filters-panel.open {
        max-width: 880px;
        margin-left: 0;
        margin-right: auto;
    }
}
/* ---------- v0.47.0 — Dimensioni Filtri / Azzera filtri ---------- */

/* Filtri: più generoso su desktop */
.list-controls .filters-toggle {
    height: 44px;
    padding: 0 18px;
    font-size: 13px;
    gap: 8px;
}

/* Azzera filtri: più piccolo e leggero, non deve sovrastare Filtri */
.list-controls .filters-reset {
    height: 38px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: transparent;
}

/* Stato disabilitato: grigio, non cliccabile, non "respira" */
.list-controls .filters-reset:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
}

/* Su mobile: se disabilitato, sparisce (più pulito che lasciarlo grigio) */
@media (max-width: 700px) {
    .list-controls .filters-reset:disabled {
        display: none;
    }
}
/* --- Checkbox Termini e Privacy (v0.50.0) --- */
.terms-checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 20px 0;
    text-align: left;
}

.terms-checkbox-group input[type="checkbox"] {
    /* Nascondiamo la checkbox di default del browser */
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    margin: 0;
    font: inherit;
    color: currentColor;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color, #444); /* Usa il tuo colore del bordo, se hai una variabile */
    border-radius: 6px;
    cursor: pointer;
    display: grid;
    place-content: center;
    flex-shrink: 0; /* Impedisce che si schiacci su schermi piccoli */
    margin-top: 2px; /* Allinea otticamente con il testo */
    transition: all 0.2s ease-in-out;
}

/* Aggiungiamo la spunta (SVG inline in base64) quando è selezionata */
.terms-checkbox-group input[type="checkbox"]::before {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em white;
    /* Creiamo una forma a "spunta" usando clip-path */
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.terms-checkbox-group input[type="checkbox"]:checked {
    background-color: var(--accent-color, #ff6b6b); /* Il tuo arancione/rosso */
    border-color: var(--accent-color, #ff6b6b);
}

.terms-checkbox-group input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.terms-checkbox-group label {
    font-size: 0.9em;
    line-height: 1.4;
    color: var(--text-muted, #ccc); /* Colore del testo meno acceso */
    cursor: pointer;
}

/* Stile per i link all'interno del testo */
.terms-checkbox-group label a {
    color: var(--accent-color, #ff6b6b); 
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.terms-checkbox-group label a:hover {
    opacity: 0.8;
    text-decoration: underline;
}
/* --- Messaggi Flash (v0.50.0) --- */
.flash-messages {
    margin-bottom: 20px;
    width: 100%;
}

.flash-alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.95em;
    text-align: center;
    font-weight: 500;
}

/* Colore per gli errori */
.flash-alert.error {
    background-color: rgba(255, 107, 107, 0.1); 
    border: 1px solid #ff6b6b; 
    color: #ff6b6b;
}

/* Colore per i successi (es. registrazione completata) */
.flash-alert.success {
    background-color: rgba(76, 175, 80, 0.1); 
    border: 1px solid #4CAF50; 
    color: #4CAF50;
}