/* YouppyPsycho. I colori stanno tutti qui sotto, una volta per il tema chiaro e una per lo scuro. */
@font-face { font-family: 'Baloo 2'; src: url('/caratteri/Baloo2.ttf') format('truetype'); font-weight: 400 800; font-display: swap; }

[data-tema="chiaro"] {
  --sfondo: #f2f6f5; --carta: #ffffff; --testo: #142420; --tenue: #6a7a76; --linea: #e3ebe9;
  --accento: #2a9d8f; --accento-forte: #218074; --su-accento: #ffffff; --accento-tenue: #dcf0ec;
  --giallo: #e9b949; --rosso: #d9544f; --verde: #2a9d8f;
  --ombra: 0 2px 14px rgba(20, 60, 55, .08); --interruttore: #d3ddda;
}
[data-tema="scuro"] {
  --sfondo: #11161a; --carta: #1a2228; --testo: #e9f1ef; --tenue: #8ba09b; --linea: #283238;
  --accento: #3fb6a6; --accento-forte: #5bc7b8; --su-accento: #0b1114; --accento-tenue: #1d322f;
  --giallo: #f0c868; --rosso: #ff6f6a; --verde: #3fb6a6;
  --ombra: 0 2px 14px rgba(0, 0, 0, .4); --interruttore: #39454b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--sfondo); color: var(--testo); font: 16px/1.45 system-ui, 'Segoe UI', Roboto, sans-serif; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--giallo); outline-offset: 2px; }
h1, h2, h3 { font-family: 'Baloo 2', system-ui, sans-serif; margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: var(--accento); }
[hidden] { display: none !important; }
.icona { display: inline-flex; width: 24px; height: 24px; flex: none; }
.icona svg { width: 100%; height: 100%; }

#app { height: 100dvh; max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; background: var(--sfondo); position: relative; overflow: hidden; }
#vista { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 660px) { body { background: color-mix(in srgb, var(--sfondo) 82%, var(--accento) 18%); } #app { box-shadow: 0 0 60px rgba(10, 50, 45, .18); } }

/* ---- barra in basso ---- */
#barra { display: flex; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--carta); border-top: 1px solid var(--linea); z-index: 2; }
#barra button { flex: 1; min-width: 0; white-space: nowrap; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 3px; color: var(--tenue); font-size: 11.5px; font-weight: 600; border-radius: 14px; position: relative; }
#barra button.attiva { color: var(--accento); }
#barra button.attiva .icona { background: var(--accento-tenue); border-radius: 12px; }
#barra .icona { width: 46px; height: 28px; padding: 3px 11px; transition: background .2s; }
#barra .pallino { position: absolute; top: 3px; right: calc(50% - 24px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--rosso); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--carta); }

/* ---- pezzi comuni ---- */
.pagina { padding: calc(14px + env(safe-area-inset-top)) 16px 28px; display: flex; flex-direction: column; gap: 14px; }
.testata { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.testata h1 { flex: 1; min-width: 0; font-size: clamp(23px, 7vw, 28px); font-weight: 800; }
.testata h1 b { color: var(--accento); }
.sotto-testata { color: var(--tenue); font-size: 14px; margin-top: -6px; }
.tondo { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--tenue); transition: background .15s, transform .1s; }
.tondo:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.tondo:active { transform: scale(.92); }
.tondo.pieno { background: var(--accento); color: var(--su-accento); box-shadow: 0 6px 16px color-mix(in srgb, var(--accento) 40%, transparent); }
.carta { background: var(--carta); border-radius: 22px; padding: 16px; box-shadow: var(--ombra); }
.carta.liscia { box-shadow: none; border: 1px solid var(--linea); }
.nota { color: var(--tenue); font-size: 14px; }
.nota.centro { text-align: center; }
.bottone { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px; border-radius: 18px; background: var(--accento); color: var(--su-accento); font-weight: 700; font-family: 'Baloo 2', system-ui, sans-serif; font-size: 17px; transition: transform .1s, background .15s; }
.bottone:hover { background: var(--accento-forte); }
.bottone:active { transform: scale(.97); }
.bottone:disabled { opacity: .45; cursor: default; transform: none; }
.bottone.secondo { background: var(--accento-tenue); color: var(--accento); }
.tenue { color: var(--tenue); }
.piccolo { font-size: 14px; }
.sostieni-youppy a { text-decoration: none; }
.sostieni-youppy h2 { text-transform: none; letter-spacing: 0; font-size: 20px; }
.bottone.secondario { background: var(--accento-tenue); color: var(--accento); }
.bottone.chiaro { background: var(--sfondo); color: var(--testo); }
.bottone.pericolo { background: none; color: var(--rosso); }
.bottone.largo { width: 100%; }
.bottone.piccolo { min-height: 40px; font-size: 15px; padding: 0 16px; border-radius: 14px; }
.pillola { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--accento-tenue); color: var(--accento); font-weight: 700; font-size: 13px; white-space: nowrap; }
.pillola.tenue { background: var(--sfondo); color: var(--tenue); }
.pillola.gialla { background: color-mix(in srgb, var(--giallo) 22%, transparent); color: color-mix(in srgb, var(--giallo) 70%, var(--testo)); }
.pillola.rossa { background: color-mix(in srgb, var(--rosso) 16%, transparent); color: var(--rosso); }
.pillola .icona { width: 15px; height: 15px; }
.vuoto { text-align: center; padding: 40px 20px; color: var(--tenue); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vuoto > .icona { width: 54px; height: 54px; color: var(--linea); }
.vuoto h3 { color: var(--testo); font-size: 20px; }

/* campi */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > span { font-size: 13px; font-weight: 700; color: var(--tenue); }
.campo input, .campo select, .campo textarea { background: var(--sfondo); border: 1px solid var(--linea); border-radius: 14px; padding: 12px 14px; min-height: 48px; width: 100%; }
.campo textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--accento); outline: none; }
.righe { display: flex; flex-direction: column; gap: 12px; }
.coppia { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; background: var(--sfondo); border: 1px solid var(--linea); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; min-height: 40px; border-radius: 11px; font-weight: 700; color: var(--tenue); }
.seg button[aria-pressed="true"] { background: var(--accento); color: var(--su-accento); }

/* interruttore */
.riga-switch { display: flex; align-items: center; gap: 12px; }
.riga-switch .txt { flex: 1; min-width: 0; }
.riga-switch .txt b { display: block; }
.riga-switch .txt span { color: var(--tenue); font-size: 13px; }
.interruttore { width: 52px; height: 32px; border-radius: 16px; background: var(--interruttore); position: relative; flex: none; transition: background .2s; }
.interruttore::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); transition: transform .2s; }
.interruttore[aria-checked="true"] { background: var(--accento); }
.interruttore[aria-checked="true"]::after { transform: translateX(20px); }

/* ---- scheda professionista nell'elenco ---- */
.prof-lista { display: flex; flex-direction: column; gap: 12px; }
.prof-card { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; text-align: left; width: 100%; }
.avatar { width: 56px; height: 56px; flex: none; border-radius: 18px; background: var(--accento-tenue); color: var(--accento); display: grid; place-items: center; font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 800; font-size: 24px; overflow: hidden; }
.prof-card .corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prof-card .corpo .nome { font-weight: 800; font-size: 18px; }
.prof-card .corpo .riga2 { color: var(--tenue); font-size: 14px; }
.prof-card .corpo .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---- dettaglio / video ---- */
.video-box { width: 100%; aspect-ratio: 16/10; border-radius: 18px; background: #000; overflow: hidden; display: grid; place-items: center; }
.video-box video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-box.vuoto { background: var(--accento-tenue); color: var(--accento); aspect-ratio: 16/10; border-radius: 18px; }
.fascia { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--linea); }
.fascia:first-child { border-top: 0; }
.fascia .quando { flex: 1; min-width: 0; }
.fascia .quando b { display: block; font-size: 15px; }
.fascia .quando span { color: var(--tenue); font-size: 13px; }
.rich-card { padding: 14px 0; border-top: 1px solid var(--linea); display: flex; flex-direction: column; gap: 8px; }
.rich-card:first-child { border-top: 0; }
.rich-card .testa { display: flex; align-items: center; gap: 8px; }
.rich-card .testa b { flex: 1; min-width: 0; }
.rich-card .msg { color: var(--tenue); font-size: 14px; background: var(--sfondo); border-radius: 12px; padding: 10px 12px; }
.rich-card .azioni { display: flex; gap: 8px; flex-wrap: wrap; }

/* avviso emergenza */
.emergenza { display: flex; gap: 10px; align-items: flex-start; background: color-mix(in srgb, var(--rosso) 10%, var(--carta)); border: 1px solid color-mix(in srgb, var(--rosso) 30%, transparent); border-radius: 16px; padding: 12px 14px; font-size: 13.5px; }
.emergenza .icona { color: var(--rosso); width: 22px; height: 22px; flex: none; }

/* ---- strato (foglio che sale dal basso) ---- */
#strati { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(10, 25, 22, .45); opacity: 0; transition: opacity .2s; pointer-events: auto; }
.foglio { position: absolute; left: 0; right: 0; bottom: 0; max-width: 620px; margin: 0 auto; background: var(--carta); border-radius: 24px 24px 0 0; max-height: 92dvh; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .25s cubic-bezier(.3,.8,.3,1); pointer-events: auto; }
#strati.aperto .scrim { opacity: 1; }
#strati.aperto .foglio { transform: translateY(0); }
.foglio .barra-foglio { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--linea); }
.foglio .barra-foglio h2 { flex: 1; min-width: 0; font-size: 20px; }
.foglio .dentro { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.maniglia { width: 40px; height: 4px; border-radius: 2px; background: var(--linea); margin: 8px auto 0; }

/* brindisi */
#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--testo); color: var(--carta); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 60; pointer-events: none; max-width: 90%; text-align: center; }
#toast.mostra { opacity: 1; transform: translateX(-50%) translateY(0); }

.rec-stato { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--rosso); }
.rec-stato .punto { width: 10px; height: 10px; border-radius: 50%; background: var(--rosso); animation: lampo 1s infinite; }
@keyframes lampo { 50% { opacity: .3; } }
.file-nasc { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- schede a tutta altezza (reel e IA) ---- */
#vista.pieno { overflow: hidden; display: flex; flex-direction: column; position: relative; }
#vista.nero { background: #000; }
.avatar.piccolo { width: 38px; height: 38px; border-radius: 50%; font-size: 15px; }

/* ---- reel ---- */
.reel-seg { position: absolute; z-index: 3; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, .35); backdrop-filter: blur(8px); }
.reel-seg button { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 14px; border-radius: 999px; color: rgba(255, 255, 255, .8); font-weight: 700; font-size: 14px; }
.reel-seg button .icona { width: 16px; height: 16px; }
.reel-seg button[aria-pressed="true"] { background: #fff; color: #000; }
.reel-feed { flex: 1; min-height: 0; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.reel-feed::-webkit-scrollbar { display: none; }
.reel-vuoto { color: rgba(255, 255, 255, .7); height: 100%; justify-content: center; }
.reel-vuoto h3 { color: #fff; }
.reel-vuoto > .icona { color: rgba(255, 255, 255, .3); }
.reel { position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; background: #000; overflow: hidden; color: #fff; }
.reel > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.reel-ombra { position: absolute; inset: auto 0 0 0; height: 55%; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); pointer-events: none; }
.reel-info { position: absolute; left: 16px; right: 92px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.reel-prof { display: flex; align-items: center; gap: 10px; text-align: left; color: #fff; }
.reel-prof .avatar { border: 2px solid #fff; }
.reel-prof b { display: block; font-size: 16px; }
.reel-prof small { display: block; font-size: 13px; opacity: .85; }
.reel-did { font-size: 14.5px; line-height: 1.4; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); white-space: pre-wrap; max-height: 6em; overflow-y: auto; }
.reel-lato { position: absolute; right: 8px; bottom: 22px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.reel-az { display: flex; flex-direction: column; align-items: center; gap: 3px; color: #fff; font-size: 12px; font-weight: 700; min-width: 64px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.reel-az .icona { width: 46px; height: 46px; padding: 10px; border-radius: 50%; background: rgba(0, 0, 0, .3); transition: transform .12s; }
.reel-az:active .icona { transform: scale(.88); }
.reel-az .emo { width: 46px; height: 46px; display: grid; place-items: center; font-size: 26px; border-radius: 50%; background: rgba(0, 0, 0, .3); }
.reel-az.acceso .icona { color: #ff4f6d; }
.reel-az.acceso .icona svg { fill: currentColor; }
.reel-az[aria-label="Salva"].acceso .icona { color: var(--giallo); }
.reel-emoji { position: absolute; right: 76px; max-width: calc(100% - 92px); overflow-x: auto; scrollbar-width: none; display: flex; gap: 2px; padding: 6px; border-radius: 999px; background: rgba(20, 20, 20, .85); backdrop-filter: blur(8px); z-index: 4; animation: sali .15s ease-out; }
.reel-emoji button { position: relative; width: 44px; height: 44px; border-radius: 50%; font-size: 26px; display: grid; place-items: center; transition: transform .1s; }
.reel-emoji button:hover { transform: scale(1.2); }
.reel-emoji button.scelta { background: rgba(255, 255, 255, .2); }
.reel-emoji small { position: absolute; bottom: -2px; right: -2px; font-size: 10px; font-weight: 700; color: #fff; background: #000; border-radius: 6px; padding: 0 3px; }
@keyframes sali { from { opacity: 0; transform: translateY(8px); } }
.reel-audio { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 34px; background: rgba(0, 0, 0, .45); border-radius: 50%; width: 72px; height: 72px; display: grid; place-items: center; pointer-events: none; }
.cuore-volante { position: absolute; top: 50%; left: 50%; color: #ff4f6d; pointer-events: none; animation: cuore .9s ease-out forwards; }
.cuore-volante .icona { width: 110px; height: 110px; }
.cuore-volante svg { fill: currentColor; }
@keyframes cuore { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -90%) scale(1); } }
.video-box.verticale { aspect-ratio: 9/16; max-height: 46dvh; width: auto; margin: 0 auto; }

/* reel nella scheda del professionista */
.reel-griglia { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.reel-mini { position: relative; aspect-ratio: 9/16; border-radius: 14px; overflow: hidden; background: #000; }
.reel-mini video { width: 100%; height: 100%; object-fit: cover; }
.reel-mini .conti { position: absolute; left: 6px; bottom: 6px; display: flex; align-items: center; gap: 3px; color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.reel-mini .conti .icona { width: 14px; height: 14px; }
.reel-mini .tondo { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; background: rgba(0, 0, 0, .5); color: #fff; }
.reel-mini .tondo .icona { width: 18px; height: 18px; }

/* commenti */
.commenti { display: flex; flex-direction: column; gap: 14px; }
.commento { display: flex; gap: 10px; align-items: flex-start; }
.commento .corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.commento .chi { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.commento .chi small { color: var(--tenue); font-size: 12px; }
.commento .chi .pillola { min-height: 20px; padding: 0 8px; font-size: 11px; }
.commento p { white-space: pre-wrap; overflow-wrap: anywhere; }
.commento .gif, .gif-scelta img { max-width: 200px; max-height: 200px; border-radius: 12px; display: block; }
.commento .tondo { width: 34px; height: 34px; }
.commento .tondo .icona { width: 18px; height: 18px; }
.scrivi-commento { position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--carta); border-top: 1px solid var(--linea); display: flex; flex-direction: column; gap: 8px; }
.emoji-rapide { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.emoji-rapide button { font-size: 22px; width: 40px; height: 40px; flex: none; border-radius: 50%; }
.emoji-rapide button:hover { background: var(--sfondo); }
.gif-scelta { position: relative; align-self: flex-start; }
.gif-scelta .tondo { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; background: rgba(0, 0, 0, .55); color: #fff; }
.scrivi-commento .riga, .chat-scrivi .riga { display: flex; align-items: flex-end; gap: 8px; }
.scrivi-commento textarea, .chat-scrivi textarea { flex: 1; min-width: 0; resize: none; background: var(--sfondo); border: 1px solid var(--linea); border-radius: 22px; padding: 10px 16px; min-height: 44px; max-height: 140px; line-height: 1.4; }
.scrivi-commento textarea:focus, .chat-scrivi textarea:focus { outline: none; border-color: var(--accento); }
.scrivi-commento label.tondo { cursor: pointer; }
.scrivi-commento .bottone-gif { font: 800 12px/1 system-ui, sans-serif; letter-spacing: .5px; }
.commento img.ygif-msg { max-width: 200px; max-height: 200px; }
.tondo:disabled { opacity: .45; }

/* ---- IA ---- */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-testa { padding: calc(14px + env(safe-area-inset-top)) 16px 10px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--linea); }
.chat-testa .sotto-testata { margin-top: 0; }
.chat-elenco { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.bolla { max-width: 85%; padding: 10px 14px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.bolla.ia { align-self: flex-start; background: var(--carta); box-shadow: var(--ombra); border-bottom-left-radius: 6px; }
.bolla.io { align-self: flex-end; background: var(--accento); color: var(--su-accento); border-bottom-right-radius: 6px; }
.bolla.scrive { display: flex; gap: 5px; padding: 14px 16px; }
.bolla.scrive span { width: 8px; height: 8px; border-radius: 50%; background: var(--tenue); animation: punti 1.2s infinite; }
.bolla.scrive span:nth-child(2) { animation-delay: .2s; }
.bolla.scrive span:nth-child(3) { animation-delay: .4s; }
@keyframes punti { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.chat-scrivi { padding: 10px 12px; border-top: 1px solid var(--linea); background: var(--carta); display: flex; flex-direction: column; gap: 4px; }
.chat-resto { font-size: 12px; text-align: center; }
.chat-resto:empty { display: none; }
.ia-intro ul { margin: 10px 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; }
.emergenza.forte { font-size: 14px; flex: none; }
.emergenza .numeri { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.emergenza .numeri a { color: inherit; text-decoration: none; }
.emergenza .numeri a b { color: var(--rosso); display: inline-block; min-width: 46px; }
