/* =====================================================================
   Lista Spesa — stile unico per app e sito
   ===================================================================== */

:root {
    --bg: #f4f6f1;
    --surface: #ffffff;
    --surface-2: #eef2ea;
    --ink: #1d2b22;
    --muted: #66746a;
    --line: #dfe6da;
    --brand: #2f7d4f;
    --brand-strong: #256641;
    --brand-ink: #ffffff;
    --brand-soft: #dcefe2;
    --accent: #f29e38;
    --accent-soft: #fdebd3;
    --danger: #c9473f;
    --danger-soft: #f9e0de;
    --info-soft: #e1ecf7;
    --shadow: 0 1px 2px rgba(29, 43, 34, .06), 0 6px 18px rgba(29, 43, 34, .06);
    --radius: 18px;
    --radius-sm: 12px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101612;
        --surface: #18211b;
        --surface-2: #1f2a22;
        --ink: #e9f0ea;
        --muted: #98a69b;
        --line: #2b382f;
        --brand: #55b57d;
        --brand-strong: #6cc790;
        --brand-ink: #0b2415;
        --brand-soft: #1d3a28;
        --accent: #f5ad55;
        --accent-soft: #3d2c16;
        --danger: #ef7a72;
        --danger-soft: #3d1f1d;
        --info-soft: #1b2a3a;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Apple SD Gothic Neo", "Malgun Gothic",
        "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK JP", "Noto Sans CJK KR", "Noto Sans CJK SC", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h1:focus, h1:focus-visible { outline: none; } /* il router mette il focus sul titolo a ogni pagina */
h2 { font-size: 1.05rem; }
a { color: var(--brand); }
p { margin: .4rem 0; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.center { text-align: center; justify-content: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.full { width: 100%; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; }
.row-gap { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .3rem 0; }
.error { color: var(--danger); font-weight: 600; margin: .2rem 0; }
.ok { color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------------- struttura */

.app-shell { max-width: 680px; margin: 0 auto; min-height: 100vh; padding-bottom: 2.5rem; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem .8rem;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 750;
    font-size: 1.08rem;
    color: var(--ink);
    text-decoration: none;
    min-width: 0;
}

.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }

.content { padding: .9rem .9rem 1rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .78rem;
    font-weight: 700;
    padding: .2rem .55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.chip-offline { background: var(--surface-2); color: var(--muted); }
.chip-warn { background: var(--accent-soft); color: #a65f08; }

@media (prefers-color-scheme: dark) { .chip-warn { color: var(--accent); } }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin: 0 0 .8rem;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    margin: .2rem 0 .6rem;
}

.page-head h1 { margin: 0; min-width: 0; }
.page-title { margin: .2rem 0 .9rem; }
.head-actions { display: flex; gap: .3rem; flex: none; }

.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin: 0 0 .6rem; }

/*
 * Ricerca (liste o prodotti), sempre sulla stessa riga dell'ordinamento: prende tutto lo spazio che resta.
 * Se è davvero poco (schermi minuscoli) si vede solo la lente.
 */
.list-search { position: relative; flex: 1 1 0; min-width: 2.6rem; container-type: inline-size; }
.list-search .search-input {
    min-height: 40px;
    padding: .4rem .4rem .4rem 2.05rem;
    border-radius: 999px;
    background: var(--surface-2);
    border-color: transparent;
    font-size: .95rem;
    text-overflow: ellipsis;
}
.list-search .search-input::placeholder { color: var(--muted); }
.list-search .search-input:focus { background: var(--surface); }
.toolbar.searching .list-search .search-input { padding-right: 2.2rem; }
/* via la "x" del browser (c'è già la nostra, uguale ovunque): con display:none non occupa nemmeno spazio */
.search-input::-webkit-search-cancel-button, .search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-icon {
    position: absolute;
    left: .7rem;
    top: 50%;
    width: 1.05rem;
    height: 1.05rem;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--muted);
    stroke-width: 2.4;
    stroke-linecap: round;
    pointer-events: none;
}
.search-clear {
    position: absolute;
    right: .3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.search-clear:hover { background: var(--surface); color: var(--ink); }
.empty-search { text-align: center; padding: 1.2rem 1rem; margin: 0 0 .6rem; }
/* poco spazio: solo la lente (il testo segnaposto non ci starebbe) */
@container (max-width: 7rem) {
    .list-search .search-input { padding-right: .3rem; }
    .list-search .search-input::placeholder { color: transparent; }
}

.loading { display: grid; place-items: center; min-height: 40vh; }

.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid var(--brand-soft);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

/* ---------------------------------------------------------------- pulsanti e campi */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 44px;
    padding: .55rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    transition: transform .08s ease, background-color .15s ease;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-lg { min-height: 52px; font-size: 1.05rem; }
.btn-sm { min-height: 36px; padding: .35rem .75rem; font-size: .9rem; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 1.2rem;
    text-decoration: none;
    cursor: pointer;
    flex: none;
}

.icon-btn:hover, .icon-btn.active { background: var(--surface-2); }
.icon-btn.small { width: 34px; height: 34px; font-size: 1rem; }

.link-btn {
    border: 0;
    background: none;
    color: var(--brand);
    font: inherit;
    font-weight: 650;
    padding: .4rem 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.label { font-weight: 650; font-size: .92rem; margin-top: .2rem; }

.input {
    width: 100%;
    min-height: 46px;
    padding: .6rem .8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.code-input { font-size: 1.4rem; text-align: center; letter-spacing: .4em; }

/* ordinamento: pulsante compatto con menu */
.sort-picker { position: relative; flex: none; }
.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 40px;
    padding: .4rem .8rem .4rem .7rem;
    border: 0;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: .9rem;
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
}
.sort-btn:hover, .sort-btn.open { background: var(--brand-soft); }
.sort-icon { width: 1rem; height: 1rem; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sort-btn .caret { color: var(--muted); font-size: .75rem; }
.sort-backdrop { position: fixed; inset: 0; z-index: 30; }
.sort-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 31;
    width: max-content;
    min-width: 11rem;
    max-width: min(20rem, calc(100vw - 2rem));
    list-style: none;
    margin: 0;
    padding: .35rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    animation: rise .15s ease;
}
.sort-menu button {
    display: flex;
    align-items: center;
    gap: .55rem;
    width: 100%;
    border: 0;
    border-radius: 11px;
    background: none;
    color: var(--ink);
    font: inherit;
    text-align: left;
    padding: .55rem .7rem;
    cursor: pointer;
}
.sort-menu button:hover { background: var(--surface-2); }
.sort-menu button.on { background: var(--brand-soft); }
.sort-check { width: 1rem; flex: none; color: var(--brand); font-weight: 800; }
.sort-name { font-weight: 650; }

.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.segmented button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .85rem;
    font-weight: 650;
    padding: .35rem .75rem;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}

.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented.wide { display: flex; width: 100%; margin-bottom: .8rem; }
.segmented.wide button { flex: 1; padding: .55rem; font-size: .95rem; }

/* ---------------------------------------------------------------- pagina principale */

.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }

.list-card {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding-right: .4rem;
}

.list-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .8rem 1rem .8rem .8rem;
    color: var(--ink);
    text-decoration: none;
}

.list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }

/* icona della lista: emoji scelta o iniziale del nome */
.list-icon {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 14px;
    background: var(--surface-2);
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1;
}
.list-icon.big { width: 2.5rem; height: 2.5rem; font-size: 1.4rem; }
.list-icon.small { width: 1.9rem; height: 1.9rem; font-size: 1.05rem; border-radius: 10px; }
.list-icon.small.letter { font-size: .85rem; }
.list-icon.letter { font-family: inherit; font-size: 1.15rem; font-weight: 800; }
.list-icon.big.letter { font-size: 1.1rem; }
.tone-0 { background: #dcefe2; color: #256641; }
.tone-1 { background: #fdebd3; color: #a65f08; }
.tone-2 { background: #e1ecf7; color: #2a5d8f; }
.tone-3 { background: #f3e1f1; color: #8a3a80; }
.tone-4 { background: #f9e0de; color: #a3392f; }
.tone-5 { background: #e8ebd6; color: #5c6420; }

@media (prefers-color-scheme: dark) {
    .tone-0 { background: #1d3a28; color: #8fd6aa; }
    .tone-1 { background: #3d2c16; color: #f5c27f; }
    .tone-2 { background: #1b2a3a; color: #9cc4ec; }
    .tone-3 { background: #36203a; color: #e2a6d9; }
    .tone-4 { background: #3d1f1d; color: #f2a39c; }
    .tone-5 { background: #2c2f1a; color: #cdd58a; }
}

/* scelta dell'icona */
.icon-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr));
    gap: .35rem;
    margin-bottom: .4rem;
}
.icon-choice {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--surface-2);
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}
.icon-choice:hover { border-color: var(--line); }
.icon-choice.on { border-color: var(--brand); background: var(--brand-soft); }
.icon-choice .list-icon { width: 78%; height: 78%; border-radius: 9px; font-size: 1rem; }

.list-name { font-weight: 700; font-size: 1.08rem; display: flex; align-items: center; gap: .4rem; overflow-wrap: anywhere; }
.list-meta { color: var(--muted); font-size: .9rem; }
.badge { font-size: .85rem; }
.chevron { color: var(--muted); font-size: 1.3rem; padding: 0 .4rem; }

.actions-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin: .9rem 0; }
.actions-bar .btn { flex: 1 1 auto; }

.hint-card { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--ink); }
.hint-card-icon { font-size: 1.6rem; }

.empty { text-align: center; padding: 1.6rem 1rem; }
.empty-icon { font-size: 2.6rem; margin-bottom: .3rem; }
.empty .btn { margin-top: .6rem; }

/* ---------------------------------------------------------------- lista */

.list-title { font-size: 1.45rem; }

.title-btn {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    padding: 0;
    text-align: left;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.banner {
    border-radius: var(--radius-sm);
    padding: .7rem .9rem;
    margin: 0 0 .8rem;
}

.banner p { margin: 0 0 .4rem; }
.banner p:last-child { margin-bottom: 0; }
.banner.warn { background: var(--accent-soft); }
.banner.info { background: var(--info-soft); }

.add-box { display: flex; gap: .5rem; position: sticky; top: 61px; z-index: 10; padding: .3rem 0; background: var(--bg); }
.add-box .input { min-height: 50px; font-size: 1.05rem; }
.add-btn { width: 52px; min-height: 50px; font-size: 1.5rem; padding: 0; }
.add-btn.idle { opacity: .5; }

.suggestions {
    list-style: none;
    margin: .2rem 0 .6rem;
    padding: .3rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.suggestions button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 44px;
    padding: .4rem .6rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.suggestions button:hover { background: var(--surface-2); }

.kind { font-size: .72rem; font-weight: 700; padding: .12rem .45rem; border-radius: 999px; white-space: nowrap; }
.kind-taken { background: var(--brand-soft); color: var(--brand); }
.kind-inlist { background: var(--surface-2); color: var(--muted); }
.kind-otherlist { background: var(--info-soft); color: var(--ink); }

.feedback { color: var(--brand); font-weight: 650; margin: .2rem 0 .4rem; }

.section { margin-top: 1rem; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.section-head h2, .section-toggle h2 { display: flex; align-items: center; gap: .45rem; margin: 0 0 .4rem; }

.count {
    display: inline-grid;
    place-items: center;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 .4rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: .8rem;
}

.total { font-weight: 700; color: var(--brand); white-space: nowrap; }

.section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    padding: .3rem 0;
    cursor: pointer;
}

.empty-line { color: var(--muted); text-align: center; padding: 1.1rem .5rem; }

.items {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.item {
    display: flex;
    align-items: center;
    gap: .3rem;
    min-height: 56px;
    padding: .25rem .5rem .25rem .6rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    transition: background-color .3s ease;
}

.item:last-child { border-bottom: 0; }
.item.highlight { background: var(--brand-soft); }

.check {
    flex: none;
    width: 30px;
    height: 30px;
    margin: 0 .3rem 0 0;
    border-radius: 50%;
    border: 2px solid var(--brand);
    background: transparent;
    color: var(--brand-ink);
    font-size: .95rem;
    font-weight: 800;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.check:hover { background: var(--brand-soft); }
.check.on { background: var(--brand); }

.item-name {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: .05rem;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 1.02rem;
    text-align: left;
    cursor: pointer;
    overflow-wrap: anywhere;
    padding: .3rem 0;
}

.item-title { display: flex; align-items: center; gap: .4rem; max-width: 100%; }
/* inizio della descrizione, più sbiadito, su una riga */
.item-note { max-width: 100%; color: var(--muted); opacity: .85; font-size: .84rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.items.taken .item-name { color: var(--muted); }
.items.taken .item-title { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }

.unsent { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); }

.price {
    flex: none;
    min-height: 36px;
    padding: .25rem .6rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: .9rem;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
}

.price.empty { background: transparent; border-style: dashed; color: var(--muted); font-weight: 500; }
.price-tag { color: var(--muted); font-size: .88rem; white-space: nowrap; }

.drag-handle {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 44px;
    color: var(--muted);
    font-size: 1.3rem;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.sortable .dragging {
    position: relative;
    z-index: 5;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
    transition: none !important;
    cursor: grabbing;
}

.is-dragging > :not(.dragging) { transition: transform .18s ease; }
.is-dragging { user-select: none; -webkit-user-select: none; }
.items.is-dragging { overflow: visible; }

.sync-line { margin-top: 1.4rem; }

/* ---------------------------------------------------------------- finestre */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(10, 16, 12, .45);
    animation: fade .15s ease;
}

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow: auto;
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: rise .2s ease;
}

@media (min-width: 640px) {
    .modal-backdrop { align-items: center; }
    .modal { border-radius: 22px; }
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }

.modal-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .8rem .8rem .3rem 1.1rem;
    background: var(--surface);
}

.modal-header h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.modal-header .icon-btn { margin-left: auto; } /* la X resta a destra anche nelle finestre senza titolo */

/* menù dei tre puntini: nome della lista al centro */
.modal.compact .modal-header { display: grid; grid-template-columns: 2.6rem 1fr 2.6rem; padding: .8rem .8rem .3rem; }
.modal.compact .modal-header h2 { grid-column: 2; text-align: center; }
.modal.compact .modal-header .icon-btn { grid-column: 3; justify-self: end; margin-left: 0; }

/* finestra del prodotto: il nome in alto, modificabile toccandolo */
.modal-header-content { position: relative; flex: 1; min-width: 0; }
.title-input {
    width: 100%;
    margin-left: -.5rem;
    padding: .3rem 1.9rem .3rem .5rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    text-overflow: ellipsis;
}
.title-input:hover { border-color: var(--line); }
.title-input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; background: var(--surface); }
.title-pencil { position: absolute; right: .2rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .95rem; cursor: text; }
.modal-header-content:focus-within .title-pencil { display: none; }

.field-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.dept-select { width: auto; max-width: 66%; flex: 0 1 auto; }

/* reparti */
.to-buy > .items + .dept-head { margin-top: 1rem; }
.dept-head { display: flex; align-items: center; gap: .45rem; margin: .3rem 0 .45rem .2rem; font-size: .82rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* interruttore nel menù dei tre puntini */
.menu .toggle-row { border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); padding: .5rem .7rem .5rem 1.1rem; margin: 0; }
.menu .toggle-row .setting-label { font-weight: 600; }
.field-row .label { margin: 0; }
.price-input { width: 8.5rem; flex: none; text-align: right; }
.note-input { min-height: 6.5rem; max-height: 45vh; resize: vertical; line-height: 1.4; field-sizing: content; }
.modal-body { padding: .4rem 1.1rem 1.2rem; }

.prompt .modal-body { padding-top: 1.4rem; text-align: center; }
.prompt-icon { font-size: 2.4rem; }
.prompt-lists { list-style: none; padding: 0; margin: .6rem 0 1rem; }
.prompt-lists li { display: flex; justify-content: center; align-items: baseline; gap: .5rem; flex-wrap: wrap; }

/* menù dei tre puntini: finestra stretta, voci come pulsanti stondati */
.modal-backdrop:has(.modal.compact) { align-items: center; padding: 1rem; }
.modal.compact { max-width: 320px; border-radius: 22px; padding-bottom: 0; }
.menu { display: flex; flex-direction: column; gap: .5rem; padding-top: .2rem; }

.menu-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    padding: .75rem 1.1rem;
    cursor: pointer;
}

.menu-item:hover { background: var(--brand-soft); border-color: transparent; }
.menu-item.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.menu-item.danger:hover { filter: brightness(.97); }

.toast {
    position: sticky;
    top: 62px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin: .6rem .9rem 0;
    padding: .5rem .5rem .5rem .9rem;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--bg);
}

.toast .icon-btn { color: var(--bg); }

/* ---------------------------------------------------------------- condivisione */

.share { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; }
.qr { width: 220px; height: 220px; border-radius: 14px; background: #fff; padding: 8px; image-rendering: pixelated; }
.share-code { font-size: 1.15rem; font-weight: 700; margin: .1rem 0 .4rem; }
.bullets { margin: .3rem 0 .6rem; padding-left: 1.2rem; }
.bullets li { margin: .25rem 0; }
.web-app { text-align: center; }

/* ---------------------------------------------------------------- impostazioni */

.setting-row, .setting-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    padding: .1rem 0;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
}

.setting-link { padding: 1rem; }
.setting-label { font-weight: 650; }
.setting-value { margin-left: auto; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.setting-row .chevron, .setting-link .chevron { padding: 0; }
.setting-row .setting-label + .chevron { margin-left: auto; }
.setting-expand { margin-top: .8rem; }
.form-section h2 { margin-bottom: .6rem; }

.setting-inline { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: .9rem; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; cursor: pointer; }
.toggle-text { display: flex; flex-direction: column; }

.switch {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 52px;
    height: 32px;
    border-radius: 999px;
    background: var(--line);
    position: relative;
    cursor: pointer;
    transition: background-color .15s ease;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .15s ease;
}

.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }

.language-list, .currency-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .45rem; }

.language {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-height: 46px;
    padding: .45rem .7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.language.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.language-code { font-size: .72rem; font-weight: 800; color: var(--muted); width: 1.6rem; }

.account-email { font-size: 1.05rem; overflow-wrap: anywhere; }
.danger-zone .setting-label { color: var(--danger); }

.prose h2 { margin-top: 1.2rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: .35rem 0; }

/* ---------------------------------------------------------------- benvenuto */

.welcome { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.welcome-card { width: 100%; max-width: 520px; text-align: center; padding: 1.6rem 1.2rem; }
.welcome-card h2 { margin: 1.2rem 0 .7rem; }
.welcome-card .btn { margin-top: 1.2rem; }
.welcome-logo { margin-bottom: .4rem; }

/* ---------------------------------------------------------------- errori Blazor */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom));
    background: var(--danger);
    color: #fff;
}

#blazor-error-ui a { color: #fff; font-weight: 700; margin-left: .5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* testo letto solo dai lettori di schermo */
.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;
}

/* ---------------------------------------------------------------- piatti preferiti */

.dishes { margin-top: 1.6rem; }
.dishes-title { font-size: 1.15rem; margin: 0 0 .6rem; }
.round-add {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    margin-right: .45rem;
    border: 0;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    cursor: pointer;
}
.round-add:hover { background: var(--brand); color: var(--brand-ink); }
.icon-btn.add-to-list { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.ingredient-dot { width: 1.6rem; text-align: center; color: var(--muted); flex: none; }

/* tendina "aggiungi a una lista" */
.check-list { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-direction: column; gap: .25rem; max-height: 38vh; overflow: auto; }
.check-row { display: flex; align-items: center; gap: .7rem; padding: .45rem .6rem; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.check-row input { width: 1.2rem; height: 1.2rem; accent-color: var(--brand); flex: none; }
.menu-item .grow { flex: 1; }
.menu-item:disabled { opacity: .5; cursor: default; }
.menu-item.ghost { background: transparent; border-style: dashed; }
