/* Crea il tuo cesto (prefisso cb-) */
.cb-head { padding: 54px 0 30px; background: linear-gradient(180deg, var(--sand, #EEF0FB) 0%, var(--cream, #faf7f2) 100%); }
.cb-head h1 { margin: 10px 0 0; font-family: var(--serif, Georgia, serif); font-weight: 400; font-size: 46px; line-height: 1.1; color: var(--ink, #14152B); }

.cb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 44px; align-items: start; padding-top: 30px; padding-bottom: 100px; }
.cb-main { min-width: 0; }

/* Cesti pronti */
.cb-presets { display: flex; gap: 12px; margin-bottom: 26px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; }
.cb-presets::-webkit-scrollbar { display: none; }
.cb-preset { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border: 1.5px solid var(--line, #DDDDE8); border-radius: 20px; background: #fff; font: inherit; text-align: left; cursor: pointer; transition: border-color .2s, transform .2s, box-shadow .2s; flex: none; }
.cb-preset:hover { border-color: var(--gold, #1D30D6); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20,21,43,.08); }
.cb-preset-imgs { display: flex; flex: none; }
.cb-preset-imgs img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; background: var(--sand, #EEF0FB); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.cb-preset-imgs img + img { margin-left: -14px; }
.cb-preset-txt { display: flex; flex-direction: column; min-width: 0; }
.cb-preset-txt b { font-size: 15.5px; color: var(--ink, #14152B); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-preset-txt small { font-size: 12.5px; color: var(--muted, #4A4C63); white-space: nowrap; }

.cb-tools { margin-bottom: 20px; }
.cb-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.cb-chips::-webkit-scrollbar { display: none; }
.cb-chips .n-chip { flex: none; }

/* Griglia prodotti */
.cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.cb-grid .n-skeleton { height: 280px; }
.cb-tile { display: flex; flex-direction: column; border-radius: 22px; background: #fff; border: 2px solid transparent; box-shadow: 0 6px 20px rgba(20,21,43,.06); overflow: hidden; transition: border-color .2s, transform .2s, box-shadow .2s; }
.cb-tile:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(20,21,43,.1); }
.cb-tile.in { border-color: var(--gold, #1D30D6); }
.cb-tile.out { opacity: .55; }
.cb-tile-img { position: relative; display: block; padding: 0; border: 0; background: var(--sand, #EEF0FB); cursor: pointer; }
.cb-tile-img:disabled { cursor: default; }
.cb-tile-img img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .35s ease; }
.cb-tile:hover .cb-tile-img img { transform: scale(1.04); }
.cb-badge { position: absolute; top: 10px; right: 10px; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center; background: var(--gold, #1D30D6); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 4px 12px rgba(29,48,214,.4); animation: cb-pop .3s ease; }
.cb-tile-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 14px; flex: 1; }
.cb-tile-body h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--ink, #14152B); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.cb-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.cb-tile-foot strong { font-size: 17px; font-weight: 800; white-space: nowrap; }
.cb-out { font-size: 13px; font-weight: 700; color: var(--muted, #4A4C63); }
.cb-add { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--navy, #1D30D6); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; transition: transform .15s, background .2s; }
.cb-add:hover { transform: scale(1.08); background: var(--ink, #14152B); }
.cb-step { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: var(--sand, #EEF0FB); }
.cb-step button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #fff; color: var(--ink, #14152B); font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.cb-step button:last-child { background: var(--navy, #1D30D6); color: #fff; }
.cb-step span { min-width: 24px; text-align: center; font-weight: 800; font-size: 15px; }
.cb-step.sm button { width: 30px; height: 30px; font-size: 17px; }
.cb-step.sm span { min-width: 20px; font-size: 14px; }

/* Il cesto */
.cb-side { position: sticky; top: 120px; }
.cb-sheet { padding: 22px 24px 24px; border-radius: 28px; background: #fff; border: 1.5px solid var(--line, #DDDDE8); box-shadow: 0 18px 44px rgba(20,21,43,.08); }
.cb-sheet-close { display: none; }
.cb-stage { position: relative; width: 100%; aspect-ratio: 4 / 3; margin: 0 0 6px; border-radius: 22px; background: radial-gradient(ellipse at 50% 90%, #efe4d1 0%, rgba(239,228,209,0) 70%); }
.cb-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cb-basket-front { z-index: 50; }
.cb-pile { position: absolute; inset: 0; z-index: 10; }
.cb-item { position: absolute; width: 24%; aspect-ratio: 1; object-fit: cover; border-radius: 18px; border: 3px solid #fff; background: #fff; box-shadow: 0 6px 16px rgba(20,21,43,.18); transform: translate(-50%, -50%) rotate(var(--r, 0deg)); }
.cb-item.drop { animation: cb-drop .55s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes cb-drop {
    0% { transform: translate(-50%, -260%) rotate(calc(var(--r, 0deg) - 25deg)) scale(.7); opacity: 0; }
    60% { opacity: 1; }
    100% { transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(1); opacity: 1; }
}
.cb-more { position: absolute; z-index: 60; right: 10%; top: 8%; padding: 6px 12px; border-radius: 999px; background: var(--ink, #14152B); color: #fff; font-weight: 800; font-size: 14px; }
.cb-empty { position: absolute; z-index: 5; left: 0; right: 0; top: 1%; text-align: center; font-size: 15px; line-height: 1.5; color: var(--muted, #4A4C63); }
.cb-empty b { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--navy, #1D30D6); color: #fff; font-size: 16px; }
.cb-stage.bump .cb-basket-front, .cb-stage.bump .cb-pile { animation: cb-bump .4s ease; }
@keyframes cb-bump { 0%, 100% { transform: none; } 40% { transform: translateY(5px) scaleY(.97); } 70% { transform: translateY(-2px); } }
@keyframes cb-pop { from { transform: scale(.4); } to { transform: scale(1); } }

.cb-total { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.cb-total small { display: block; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted, #4A4C63); }
.cb-total strong { display: block; font-family: var(--serif, Georgia, serif); font-weight: 400; font-size: 38px; line-height: 1.1; color: var(--ink, #14152B); }
.cb-points { padding: 6px 12px; border-radius: 999px; background: #EEF0FB; color: #1424A8; font-size: 13px; font-weight: 800; white-space: nowrap; }
.cb-ship { margin: 14px 0 6px; }
.cb-ship span { display: block; margin-top: 8px; font-size: 14px; color: var(--muted, #4A4C63); }
.cb-ship b { color: var(--ink, #14152B); }

.cb-list { list-style: none; margin: 10px 0 16px; padding: 0; max-height: 300px; overflow: auto; }
.cb-list li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--sand, #EEF0FB); }
.cb-list li:last-child { border-bottom: 0; }
.cb-list li.flash { animation: cb-flash 1s ease; }
@keyframes cb-flash { 0% { background: #EEF0FB; } 100% { background: transparent; } }
.cb-list img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: var(--sand, #EEF0FB); }
.cb-list-name { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--ink, #14152B); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cb-list b { font-size: 14.5px; white-space: nowrap; min-width: 62px; text-align: right; }
.cb-cta { min-height: 60px; font-size: 17px; }
.cb-cta:disabled { opacity: .45; cursor: not-allowed; }
.cb-clear { display: block; margin: 12px auto 0; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted, #4A4C63); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.cb-clear[hidden] { display: none; }

.cb-ghost { position: fixed; z-index: 4000; border-radius: 18px; object-fit: cover; border: 3px solid #fff; box-shadow: 0 14px 30px rgba(0,0,0,.25); pointer-events: none; }

/* Barra da telefono (nascosta su schermi grandi) */
.cb-bar, .cb-backdrop { display: none; }

@media (max-width: 1180px) {
    .cb-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; }
}

@media (max-width: 900px) {
    .cb-head { padding: 28px 0 14px; }
    .cb-head h1 { font-size: 28px; }
    .cb-layout { grid-template-columns: minmax(0, 1fr); padding-top: 16px; padding-bottom: 120px; }
    .cb-presets { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px 6px; scrollbar-width: none; }
    .cb-presets::-webkit-scrollbar { display: none; }
    .cb-preset { flex: none; padding: 8px 12px 8px 8px; border-radius: 18px; }
    .cb-preset-imgs img { width: 34px; height: 34px; }
    .cb-tools { margin: 0 -16px 14px; padding: 0 16px; }
    .cb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .cb-tile { border-radius: 18px; }
    .cb-tile-body { padding: 10px 10px 12px; gap: 8px; }
    .cb-tile-body h3 { font-size: 13.5px; }
    .cb-tile-foot strong { font-size: 15px; }
    .cb-add { width: 40px; height: 40px; font-size: 24px; }
    .cb-step button { width: 32px; height: 32px; font-size: 18px; }
    .cb-step span { min-width: 20px; font-size: 14px; }
    .cb-badge { top: 8px; right: 8px; min-width: 30px; height: 30px; font-size: 14px; }

    /* il cesto diventa un pannello che sale dal basso */
    .cb-side { position: static; }
    .cb-sheet { position: fixed; z-index: 2600; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; border: 0; box-shadow: 0 -16px 40px rgba(0,0,0,.2); transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.8,.2,1); }
    body.cb-sheet-open .cb-sheet { transform: none; }
    body.cb-sheet-open { overflow: hidden; }
    .cb-sheet-close { display: block; position: absolute; z-index: 70; top: 12px; right: 12px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--sand, #EEF0FB); font-size: 26px; line-height: 1; color: var(--ink, #14152B); cursor: pointer; }
    .cb-stage { max-width: 360px; margin: 0 auto 4px; }
    .cb-total strong { font-size: 32px; }
    .cb-list { max-height: none; }
    .cb-backdrop { position: fixed; inset: 0; z-index: 2500; background: rgba(28,18,12,.5); }
    body.cb-sheet-open .cb-backdrop { display: block; }

    .cb-bar { position: fixed; z-index: 2400; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1.5px solid var(--line, #DDDDE8); box-shadow: 0 -8px 24px rgba(20,21,43,.08); }
    .cb-bar-basket { position: relative; flex: none; width: 54px; height: 50px; border: 0; border-radius: 16px; background: var(--sand, #EEF0FB); cursor: pointer; }
    .cb-bar-basket svg { width: 38px; height: 32px; }
    .cb-bar-basket em { position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--gold, #1D30D6); color: #fff; font-style: normal; font-weight: 800; font-size: 13px; }
    .cb-bar-basket em[hidden] { display: none; }
    .cb-bar-basket.bump { animation: cb-bump .4s ease; }
    .cb-bar-info { flex: 1; min-width: 0; }
    .cb-bar-info small { display: block; font-size: 12.5px; color: var(--muted, #4A4C63); }
    .cb-bar-info strong { font-size: 20px; }
    .cb-bar .n-btn { min-height: 50px; padding: 0 20px; }
    .cb-page .n-mobilebar { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .cb-item.drop, .cb-stage.bump .cb-basket-front, .cb-stage.bump .cb-pile, .cb-badge, .cb-list li.flash { animation: none; }
    .cb-sheet { transition: none; }
}

/* Cesto laterale: altezza = schermo; l'elenco prodotti scorre, totale e bottone restano sempre visibili */
@media (min-width: 901px) {
    .cb-side { top: 112px; max-height: calc(100vh - 128px); display: flex; flex-direction: column; }
    .cb-sheet { display: flex; flex-direction: column; min-height: 0; max-height: 100%; overflow: hidden; }
    .cb-stage { flex: none; width: min(100%, calc(26vh * 4 / 3)); margin-left: auto; margin-right: auto; }
    .cb-total, .cb-ship, .cb-cta, .cb-clear { flex: none; }
    .cb-list { flex: 1 1 auto; min-height: 72px; max-height: none; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}
@media (max-width: 900px) {
    .cb-sheet { display: flex; flex-direction: column; overscroll-behavior: contain; }
    .cb-list { max-height: 34vh; overflow-y: auto; }
}
.cb-list-name { font-size: 16px; }
