/* TREEEND AGENDA ENGINE — Shell comune, versione di prova.
   Tutte le regole sono circoscritte al portale con shell attiva. */
#treeend-next-portal.teae-on{--teae-accent:#e90070;--teae-toolbar-height:68px;--teae-admin-offset:0px;}
#treeend-next-portal .teae-toolbar[hidden]{display:none!important;}
#treeend-next-portal.teae-on > .teae-toolbar{
    position:sticky;top:var(--teae-admin-offset);z-index:999;
    display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;
    align-items:center;min-height:60px;padding:9px 12px;margin:0 0 14px;
    border:1px solid #e3e8dd;border-radius:12px;background:rgba(255,255,252,.98);
    box-shadow:0 4px 15px rgba(25,45,25,.08);box-sizing:border-box;
}
#treeend-next-portal .teae-title{font-size:13px;letter-spacing:.08em;font-weight:900;color:#2e4120;white-space:nowrap;margin:0;}
#treeend-next-portal .teae-nav{display:flex;align-items:center;gap:4px;min-width:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin;white-space:nowrap;padding:3px 0;}
#treeend-next-portal .teae-link{appearance:none;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;
    border:0;background:transparent;padding:9px 7px;border-radius:6px;color:#375039;text-decoration:none!important;
    font:inherit;font-size:12px;font-weight:700;line-height:1.2;cursor:pointer;}
#treeend-next-portal .teae-link:hover,#treeend-next-portal .teae-link:focus-visible{background:#f0f4ec;color:#243d2b;}
#treeend-next-portal .teae-link.is-active{background:#fff0f7;color:var(--teae-accent)!important;box-shadow:inset 0 -2px 0 var(--teae-accent);}
#treeend-next-portal .teae-link:focus-visible,#treeend-next-portal .teae-nav-step:focus-visible,#treeend-next-portal .teae-language-button:focus-visible{outline:2px solid var(--teae-accent);outline-offset:2px;}
#treeend-next-portal .teae-controls{display:flex;align-items:center;gap:6px;min-width:max-content;}
#treeend-next-portal .teae-controls > .treeend-next-top-tools{position:relative!important;inset:auto!important;top:auto!important;right:auto!important;z-index:auto!important;
    display:flex!important;align-items:center!important;gap:6px!important;padding:0!important;margin:0!important;width:auto!important;min-height:0!important;}
#treeend-next-portal .teae-nav-step,#treeend-next-portal .teae-language-button,#treeend-next-portal .teae-layers-button{
    display:inline-flex;align-items:center;justify-content:center;min-height:33px;border:1px solid #dce7d8;
    border-radius:8px;background:white;color:#2e4120;font-size:14px;font-weight:750;cursor:pointer;padding:5px 8px;}
#treeend-next-portal .teae-language-button{gap:4px;border-color:#bdd7c7;background:#f4faf6;white-space:nowrap;font-size:12px;}
#treeend-next-portal .teae-language-button svg{width:17px;height:17px;stroke:#174b35;fill:none;stroke-width:1.9;display:block;flex:none;}
#treeend-next-portal .teae-control-note{font-size:11px;letter-spacing:.02em;}
#treeend-next-portal.teae-on .treeend-next-sidebar{position:sticky;top:calc(var(--teae-toolbar-height) + var(--teae-admin-offset) + 12px);max-height:calc(100vh - var(--teae-toolbar-height) - var(--teae-admin-offset) - 24px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;}
#treeend-next-portal.teae-on .tem-word-nav{display:none!important;}
#treeend-next-portal.teae-on #treeend-music .tem-head-brand{display:none;}
#treeend-next-portal.teae-on #treeend-music .tem-head{margin-bottom:8px;justify-content:flex-end;}
#treeend-next-portal.teae-on #treeend-music [data-teae-section]{scroll-margin-top:calc(var(--teae-toolbar-height) + var(--teae-admin-offset) + 20px);}
#treeend-next-portal .teae-section-heading{font-size:clamp(21px,2.25vw,27px);line-height:1.2;margin:0 0 12px;padding:0 0 6px;border-bottom:1px solid #e3e9e0;font-weight:750;color:#2e4120;text-align:left;}
#treeend-next-portal #tem-radio > .teae-section-heading{color:#fff;border-color:rgba(255,255,255,.24);margin:0 24px 10px; padding-top:15px;}
#treeend-next-portal .teae-agenda-label{margin:20px 0 12px;}
#treeend-next-portal #tem-common-agenda.teae-share-card{margin:20px auto 12px;padding:18px;border:1px solid #e3e9e0;border-radius:12px;background:#fafbf9;}
#treeend-next-portal .teae-share-card .teae-section-heading{margin-bottom:7px;}
#treeend-next-portal .teae-share-card p{margin:0;color:#647164;line-height:1.6;font-size:14px;}
#treeend-next-portal .teae-mobile-layers{display:none;position:absolute;right:10px;top:calc(100% + 4px);width:min(300px,90vw);max-height:50vh;overflow-y:auto;padding:8px;
    border-radius:11px;border:1px solid #dce5d9;background:#fff;box-shadow:0 9px 22px #0002;z-index:1000;}
#treeend-next-portal .teae-mobile-layers[hidden]{display:none!important;}
#treeend-next-portal .teae-mobile-layers button{display:block;width:100%;border:0;border-bottom:1px solid #edf0ea;background:none;padding:10px 7px;text-align:left;color:#2e4120;cursor:pointer;}
#treeend-next-portal .teae-mobile-layers button:focus-visible{outline:2px solid var(--teae-accent)}
/* Mantenere le funzioni native di account e launcher sopra il contenuto. */
#treeend-next-portal.teae-on .treeend-next-app-panel,
#treeend-next-portal.teae-on .treeend-next-account-panel{z-index:1050!important;}
@media (max-width:1180px){
    #treeend-next-portal.teae-on > .teae-toolbar{grid-template-columns:auto minmax(0,1fr) auto;gap:6px;}
    #treeend-next-portal .teae-link{padding:8px 6px;font-size:12px;}
    #treeend-next-portal .teae-control-note{display:none;}
}
@media (max-width:800px){
    #treeend-next-portal.teae-on > .teae-toolbar{grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto;row-gap:2px;padding:7px 9px;}
    #treeend-next-portal .teae-title{grid-column:1;grid-row:1;align-self:center;}
    #treeend-next-portal .teae-nav{grid-column:1 / -1;grid-row:2;width:100%;}
    #treeend-next-portal .teae-controls{grid-column:2;grid-row:1;justify-content:flex-end;}
    #treeend-next-portal .teae-layers-button{display:inline-flex;}
    #treeend-next-portal.teae-on .treeend-next-sidebar{position:relative;top:auto;max-height:none;overflow:visible;}
}
@media (min-width:801px){#treeend-next-portal .teae-layers-button{display:none;}}
@media (max-width:480px){
    #treeend-next-portal .teae-nav-step{display:none;}
    #treeend-next-portal .teae-language-button{padding:4px 7px;min-height:32px;}
    #treeend-next-portal .teae-layers-button{font-size:12px;padding:4px 7px;min-height:32px;}
    #treeend-next-portal .teae-controls > .treeend-next-top-tools{gap:2px!important;}
    #treeend-next-portal .teae-controls .treeend-next-account-button,
    #treeend-next-portal .teae-controls .treeend-next-app-launcher-button,
    #treeend-next-portal .teae-controls .treeend-next-message-bell{width:34px!important;height:34px!important;}
}
@media (prefers-reduced-motion:reduce){#treeend-next-portal .teae-link{scroll-behavior:auto!important;}}
/* ================================================================
   0.2.1 — HEADER UNICO TREEEND + IDENTITA' AGENDA + MENU SEZIONI
   La barra e' l'unico luogo con logo, payoff e simbolo dell'agenda.
   Non modifica markup e dati di TreeEnd Next. Solo .teae-on.
   ================================================================ */
#treeend-next-portal.teae-on > .teae-toolbar {
    display:grid;
    grid-template-columns:minmax(220px,255px) minmax(0,1fr) auto;
    grid-template-rows:auto auto;
    gap:2px 12px;
    align-items:center;
    padding:9px 13px 8px;
    min-height:96px;
}
#treeend-next-portal .teae-title {
    position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;
    overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;
}
#treeend-next-portal .teae-brand-logo {
    grid-column:1;grid-row:1 / span 2;
    display:flex;flex-direction:column;align-items:flex-start;justify-content:center;
    align-self:center;min-width:0;width:100%;box-sizing:border-box;
    padding-right:12px;border-right:1px solid #dfe9d8;
}
#treeend-next-portal .teae-brand-image {
    display:block;width:100%;max-width:225px;max-height:60px;height:auto;
    object-fit:contain;object-position:left center;border-radius:7px;
}
#treeend-next-portal .teae-brand-payoff {
    display:block;max-width:225px;margin-top:2px;width:100%;color:#315435;
    font:italic 14px/1.15 Georgia,'Times New Roman',serif;
    letter-spacing:.01em;text-align:center;
}
#treeend-next-portal .teae-agenda-identity {
    grid-column:2;grid-row:1;
    display:flex;align-items:center;gap:12px;
    min-width:0;padding:0 1px;
}
#treeend-next-portal .teae-identity-symbol {
    display:block;width:55px;height:55px;object-fit:contain;flex:0 0 55px;
    border-radius:9px;background:#294c32;padding:3px;box-sizing:border-box;
}
#treeend-next-portal .teae-identity-name {
    font-size:clamp(23px,2vw,31px);line-height:1.1;letter-spacing:.035em;
    font-weight:850;color:#2e4120;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
#treeend-next-portal .teae-nav {
    grid-column:2 / 4;grid-row:2;
    border-top:1px solid #edf0e9;padding:3px 0 1px;
    width:100%;max-width:100%;
}
#treeend-next-portal .teae-controls {grid-column:3;grid-row:1;justify-content:flex-end;}
#treeend-next-portal .teae-link {padding:8px 8px;font-size:12px;}
/* Logo + payoff nativi sono ripetizioni SOLO quando e' aperta una agenda
   gestita dall'Engine. Non vengono rimossi dal DOM, per Next e per altre pagine. */
#treeend-next-portal.teae-on .treeend-next-sidebar > .treeend-next-logo,
#treeend-next-portal.teae-on .treeend-next-sidebar > .treeend-sidebar-payoff {display:none!important;}
#treeend-next-portal.teae-on .treeend-next-sidebar > .treeend-next-online {margin-top:0;}
#treeend-next-portal.teae-on .treeend-next-sidebar {
    top:calc(var(--teae-toolbar-height) + var(--teae-admin-offset) + 12px);
}
#treeend-next-portal.teae-on .tem-word-nav{display:none!important;}
#treeend-next-portal.teae-on #treeend-music .tem-head-brand{display:none;}
#treeend-next-portal.teae-on #treeend-music .tem-head{margin-bottom:8px;justify-content:flex-end;}
#treeend-next-portal.teae-on #treeend-music [data-teae-section]{scroll-margin-top:calc(var(--teae-toolbar-height) + var(--teae-admin-offset) + 20px);}
/* In pagina rimangono solo i nomi funzionali, es. "Agenda": l'identita' "Hornbill MUSIC"
   compare una sola volta nella barra superiore. */
#treeend-next-portal .teae-agenda-label{display:flex;align-items:center;gap:10px;}
#treeend-next-portal.teae-on .teae-section-heading:not(.teae-agenda-label){display:flex;align-items:center;gap:10px;justify-content:space-between;}
#treeend-next-portal.teae-on .teae-section-heading .teae-pop-button{margin-left:auto;}
@media(max-width:1180px){
    #treeend-next-portal.teae-on > .teae-toolbar {grid-template-columns:minmax(175px,195px) minmax(0,1fr) auto;gap:2px 7px;}
    #treeend-next-portal .teae-brand-image{max-width:185px;}
    #treeend-next-portal .teae-brand-payoff{max-width:185px;font-size:13px;}
    #treeend-next-portal .teae-identity-symbol{width:48px;height:48px;flex-basis:48px;}
    #treeend-next-portal .teae-identity-name{font-size:24px;}
    #treeend-next-portal .teae-link{padding:8px 6px;}
}
@media(max-width:800px){
    #treeend-next-portal.teae-on > .teae-toolbar{
        grid-template-columns:minmax(0,1fr) auto;
        grid-template-rows:auto auto auto;
        padding:7px 9px;gap:4px 7px;
    }
    #treeend-next-portal .teae-brand-logo{grid-column:1;grid-row:1;border-right:0;padding-right:0;align-items:flex-start;}
    #treeend-next-portal .teae-brand-image{max-width:156px;max-height:43px;}
    #treeend-next-portal .teae-brand-payoff{max-width:156px;font-size:11px;}
    #treeend-next-portal .teae-agenda-identity{grid-column:1 / -1;grid-row:2;gap:8px;}
    #treeend-next-portal .teae-identity-symbol{width:36px;height:36px;flex-basis:36px;}
    #treeend-next-portal .teae-identity-name{font-size:22px;}
    #treeend-next-portal .teae-nav{grid-column:1 / -1;grid-row:3;}
    #treeend-next-portal .teae-controls{grid-column:2;grid-row:1;}
    #treeend-next-portal.teae-on .treeend-next-sidebar{position:relative;top:auto;max-height:none;overflow:visible;}
}
@media(max-width:480px){
    #treeend-next-portal .teae-brand-image{max-width:140px;max-height:40px;}
    #treeend-next-portal .teae-brand-payoff{max-width:140px;}
    #treeend-next-portal .teae-identity-name{font-size:21px;}
    #treeend-next-portal .teae-link{padding:8px 7px;}
}

/* ================================================================
   0.2.3 — UN SOLO TRADUCI, CON PANNELLO ORIGINALE GLOBAL LANGUAGES
   Il comando nativo accanto alla campanella resta nel DOM e conserva
   i suoi listener/salvataggi; nascondiamo soltanto la sua icona.
   La nuova voce Traduci gli inoltra il click e posiziona il pannello.
   Fuori dalle agende gestite dall'Engine non cambia nulla.
   ================================================================ */
#treeend-next-portal.teae-on .teae-controls .treeend-gl-switcher {
    position:absolute!important;width:0!important;height:0!important;
    min-width:0!important;min-height:0!important;overflow:visible!important;
}
#treeend-next-portal.teae-on .teae-controls .treeend-gl-switcher-button {
    display:none!important;
}
#treeend-next-portal.teae-on .teae-controls .treeend-gl-switcher-panel {
    z-index:1205!important;box-sizing:border-box;
    max-height:calc(100vh - 16px);overflow-y:auto;
}
@media(max-width:700px) {
    /* Global Languages 1.1.1 imposta una griglia 2x2 per quattro icone:
       rimuovendo il duplicato, ripristiniamo la fila compatta originale. */
    #treeend-next-portal.teae-on .teae-controls > .treeend-next-top-tools:has(.treeend-next-account-menu):has(.treeend-gl-switcher) {
        display:flex!important;grid-template-columns:none!important;grid-template-rows:none!important;
        align-items:center!important;justify-content:flex-end!important;gap:4px!important;
        width:auto!important;min-height:0!important;padding:0!important;
    }
    #treeend-next-portal.teae-on .teae-controls .treeend-next-account-menu,
    #treeend-next-portal.teae-on .teae-controls .treeend-next-message-bell,
    #treeend-next-portal.teae-on .teae-controls .treeend-next-app-launcher {
        grid-column:auto!important;grid-row:auto!important;order:initial!important;
    }
}

/* 0.2.4 — DESIGN eredita la barra comune, senza doppia navigazione. */
#treeend-next-portal.teae-on #treeend-design.ted-layer-active .ted-word-nav,
#treeend-next-portal.teae-on #treeend-design.ted-layer-active .ted-brand{display:none!important;}
#treeend-next-portal.teae-on #treeend-design.ted-layer-active .ted-head{justify-content:flex-end!important;align-items:center!important;margin:2px 0 12px!important;}
#treeend-next-portal.teae-on #treeend-design.ted-layer-active [data-teae-section]{scroll-margin-top:calc(var(--teae-toolbar-height) + var(--teae-admin-offset) + 20px);}
#treeend-next-portal.teae-on #treeend-design.ted-layer-active #ted-follow-pair{grid-template-columns:minmax(0,1fr)!important;}
#treeend-next-portal.teae-on #treeend-design.ted-layer-active #ted-follow,
#treeend-next-portal.teae-on #treeend-design.ted-layer-active #ted-create{width:100%;min-width:0;box-sizing:border-box;}
#treeend-next-portal.teae-on #treeend-design .teae-section-heading{color:#2e4120;font-size:clamp(19px,2vw,26px);margin:12px 0 10px;}

/* Mostra soltanto l'etichetta Agenda dell'agenda attiva, anche nei cambi layer. */
#treeend-next-portal[data-teae-agenda="design"] .teae-section-heading[data-teae-heading-agenda="music"],
#treeend-next-portal[data-teae-agenda="music"] .teae-section-heading[data-teae-heading-agenda="design"]{display:none!important;}
