/* Shared controls: SVG icons, predictable sizing, and visible keyboard focus. */
button{font:inherit;-webkit-appearance:none;appearance:none;touch-action:manipulation}
button svg{flex-shrink:0;pointer-events:none;display:block}
button:focus-visible{outline:2px solid #ff6471;outline-offset:4px}
button:disabled{cursor:default}
.nav-action,.primary-action{display:inline-flex;align-items:center;justify-content:center;gap:9px;border:1px solid #34343e;border-radius:12px;min-height:42px;padding:0 16px;background:#1a1a22;color:#ededf2;cursor:pointer;font-size:.82rem;font-weight:600;white-space:nowrap}
.nav-action:hover{background:#26262f;border-color:#555563}
.primary-action{background:#e50925;border-color:#e50925;color:white}
.primary-action:hover{background:#fa1936}
/* margin-left:auto on Libreria (the last item) pushes only itself to the
   right edge — Aggiorna stays put, icon-only, right next to the search bar. */
#library-nav{flex-shrink:0;margin-left:auto}
/* Search bar sits right after the logo and grows into the free space
   (up to max-width). */
#search-bar{min-width:60px;max-width:620px}
#update-btn{
  display:flex;align-items:center;justify-content:center;
  width:42px;height:42px;padding:0;border-radius:12px;flex-shrink:0;
  border:1px solid #34343e;background:#1a1a22;color:#ededf2;
}
#update-btn:hover{background:#26262f;border-color:#555563}
#update-btn.updating{color:#ff6471;border-color:#ff647166}
#update-btn.done{color:#3ecf7a;border-color:#3ecf7a66}
#update-icon{display:flex}
#update-label{display:none}
.scroll-row .poster-card{flex-basis:184px}
.poster-card{border-radius:14px;background:#17171f;overflow:hidden}
.poster-info{padding:12px 12px 8px}
.poster-title{font-size:.87rem;line-height:1.4;min-height:2.8em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;white-space:normal;overflow:hidden}
.poster-meta{margin-top:5px;font-size:.74rem;color:#9898aa;min-height:1.1em}
.personal-actions{display:flex;align-items:center;gap:6px;margin:12px 0 0;position:relative;z-index:2;flex-wrap:wrap}
/* flex-wrap:wrap (not nowrap): a series card can carry 5 icons (salvato/
   visto/scarica/notifica/dettagli) — nowrap forced them past the card's
   right edge on any card narrower than ~170px (every mobile scroll-row
   card, and the library grid's own minimum), clipped and unusable. Wrapping
   to a second row on narrow cards costs a little height but never overflows. */
.poster-info>.personal-actions{justify-content:flex-start;flex-wrap:wrap;border-top:1px solid #ffffff0b;padding-top:8px;gap:4px}
.action-icon,.personal-actions .action-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 34px;width:34px;height:36px;padding:0;border:1px solid transparent;border-radius:9px;background:transparent;color:#9d9dac;cursor:pointer;transition:background .15s,color .15s}
.action-icon:hover,.personal-actions .action-icon:hover{color:#fff;background:#ffffff0c}
.personal-actions .action-icon[aria-pressed=true]{background:#e5092519;border-color:transparent;color:#ff6174}
.personal-actions .action-icon:disabled{opacity:.28}
.action-icon[aria-busy=true]{animation:pulse 1s ease-in-out infinite;color:#ff6174}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
.personal-actions .primary-action{width:auto;flex:0 1 auto;height:44px;border-radius:10px;padding:0 18px;background:#e50925;border:1px solid #e50925;color:white}
/* "Dettagli" lives next to year/rating, not as a 5th icon in the action
   row below (saved/visto/scarica/notifica) -- see makePoster(). Small and
   inline with the meta text, not the full 34px touch target used there. */
.poster-meta-row{display:flex;align-items:center;justify-content:space-between;gap:6px}
.poster-info-btn{flex:0 0 22px;width:22px;height:22px;min-height:0;color:#8c8c9e}
.poster-info-btn svg{width:15px;height:15px}
.poster-info-btn:hover{color:#fff;background:#ffffff0c}
.library-heading{padding:32px 0 26px}
.eyebrow{display:block;font-size:.64rem;font-weight:700;letter-spacing:.16em;color:#eb697a;margin-bottom:12px}
.library-heading h1{font-size:clamp(1.8rem,4vw,2.75rem);letter-spacing:-.055em;line-height:1.15;margin:0 0 12px}
.library-heading p{font-size:.87rem;color:#9696a8;margin:0;line-height:1.5}
.library-tabs{display:flex;align-items:center;gap:7px;border-bottom:1px solid #282833;padding-bottom:16px;margin-bottom:25px;overflow-x:auto}
.library-tab{display:flex;align-items:center;gap:9px;min-height:44px;padding:0 15px;flex-shrink:0;background:transparent;color:#9090a2;border:1px solid transparent;border-radius:10px;font-size:.81rem;font-weight:600;cursor:pointer}
.library-tab[aria-pressed=true]{color:#f2f2f7;background:#22222d;border-color:#363645}
.tab-count{background:#ffffff0b;border-radius:6px;min-width:20px;padding:2px 5px;font-size:.65rem;text-align:center;color:#a6a6b5}
.library-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:330px;padding:40px 18px}
.empty-mark{width:72px;height:72px;display:grid;place-items:center;border:1px solid #373741;border-radius:23px;background:linear-gradient(145deg,#29232c,#14141b);color:#e97083;margin-bottom:24px;box-shadow:0 15px 70px #df143212}
.empty-mark svg{width:29px;height:29px}
.library-empty h2{font-size:1.28rem;letter-spacing:-.025em;margin:0 0 10px;font-weight:600}
.library-empty p{max-width:370px;font-size:.84rem;line-height:1.7;color:#8c8c9e;margin:0 0 25px}
.library-grid{grid-template-columns:repeat(auto-fill,minmax(165px,1fr));gap:20px;max-width:1180px}
/* The page-wide `*{margin:0}` reset also zeroes the native <dialog>'s UA
   margin:auto, which is what centers it — restore it here or the dialog
   sticks to the top-left of the viewport instead of the middle. */
/* Season grid: the same poster-card as movies/shows everywhere else (same
   cover art — the show's poster, since providers don't give per-season
   art — with an "S1" badge in the corner) instead of a one-off row style. */
.season-card .poster-badge{font-size:.72rem;padding:3px 7px}
#details-dialog{margin:auto;padding:0;background:#16161e;border:1px solid #353540;border-radius:22px;width:min(820px,calc(100vw - 32px));max-width:none;max-height:90vh;max-height:90svh;color:#fff;overflow:auto;box-shadow:0 24px 100px #0008}
#quality-dialog{margin:auto;position:relative;background:#16161e;border:1px solid #353540;border-radius:18px;width:min(360px,calc(100vw - 32px));padding:26px 24px;color:#fff;box-shadow:0 24px 100px #0008}
#quality-dialog::backdrop{background:#030309c9;backdrop-filter:blur(8px)}
#quality-close{position:absolute;right:14px;top:14px}
#quality-title{font-size:1.05rem;margin:0 0 6px}
.quality-sub{font-size:.8rem;color:#9898aa;margin:0 0 18px;line-height:1.5}
#quality-options{display:flex;flex-direction:column;gap:8px}
.quality-option{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 14px;border-radius:10px;background:#1c1c26;border:1px solid #2d2d39;cursor:pointer;transition:all .15s;color:#fff;text-align:left;font:inherit;width:100%}
.quality-option:hover{border-color:#e50925;background:#20202b}
.quality-option strong{font-size:.86rem;font-weight:700}
.quality-option span{font-size:.75rem;color:#9898aa;flex-shrink:0}
#details-dialog::backdrop{background:#030309c9;backdrop-filter:blur(8px)}
#details-close{position:absolute;right:14px;top:14px;z-index:5;background:#08080bc9;color:#fff;border:1px solid #ffffff20;border-radius:50%;width:36px;height:36px}
.details-layout{display:grid;grid-template-columns:260px minmax(0,1fr)}
#details-art{background:linear-gradient(150deg,#352631,#111118);min-height:390px;overflow:hidden}
#details-art img{width:100%;height:100%;display:block;object-fit:cover}
.details-copy{padding:38px 32px 30px;min-width:0}
#details-title{font-size:1.8rem;letter-spacing:-.04em;line-height:1.15;margin:0 18px 14px 0;overflow-wrap:anywhere}
#details-meta{color:#aaaabb;font-size:.77rem;line-height:1.7;margin-bottom:24px}
.details-copy h3{font-size:.74rem;font-weight:600;margin:0 0 8px;color:#efeff6}
#details-plot{font-size:.86rem;color:#b9b9c8;line-height:1.8;white-space:pre-line;margin:0 0 26px}
#details-actions .personal-actions{gap:8px}
/* Header is a separate row: Safari's native video controls never share its space. */
#overlay{padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));gap:0;overflow:auto}
#player-header,#player-header.hidden{position:relative;top:auto;left:auto;right:auto;display:flex;align-items:center;flex-shrink:0;width:100%;max-width:980px;box-sizing:border-box;min-height:64px;padding:12px 0;gap:12px;opacity:1;pointer-events:auto;background:none}
#player-title-text{min-width:0;flex:1 1 0;font-size:.9rem;color:#e8e8ef;line-height:1.4}
#player-header #player-close{flex:0 0 38px;width:38px;height:38px;padding:0;background:#24242c;color:#ccc;border-radius:50%;border:1px solid #34343e}
#download-btn{flex-shrink:0;font-size:.77rem}
#player-wrap{flex-shrink:0;border-radius:12px}
video#vid{display:block;max-height:calc(100vh - 125px);max-height:calc(100svh - 125px);object-fit:contain;clip-path:none;border-radius:0}
#download-status{left:auto;right:20px;bottom:20px;max-width:380px;width:calc(100vw - 40px);background:#20202b;border-color:#3a3a48;box-shadow:0 12px 40px #0006;padding:16px;border-radius:14px;font-size:.8rem}
.download-row{display:flex;align-items:center;gap:14px;margin-bottom:18px;border:1px solid #2d2d39;background:#17171f;border-radius:14px;padding:14px}
.download-row img{width:62px;height:88px;object-fit:cover;border-radius:7px}
.download-info{flex:1;min-width:0}
.download-info h3{font-size:.93rem;line-height:1.4;margin:0 0 7px}
.download-info p{font-size:.74rem;color:#9898aa;margin:0 0 9px}
.download-list{max-width:640px}
/* Active downloads panel: a cover, title + running progress bar, cancel icon. */
.download-job-row{display:flex;align-items:center;gap:12px}
.download-job-row+.download-job-row{border-top:1px solid #2d2d39;margin-top:14px;padding-top:14px}
.download-job-row img{width:36px;height:51px;object-fit:cover;border-radius:5px;flex-shrink:0}
.download-job-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:7px}
.download-job-title{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
.download-job-name{font-size:.83rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.download-job-title>span:last-child{font-size:.72rem;color:#9898aa;flex-shrink:0}
.download-job-bar{height:5px;border-radius:3px;background:#2c2c38;overflow:hidden;position:relative}
.download-job-bar>i{display:block;height:100%;width:0;background:#e50925;border-radius:3px;transition:width .3s ease}
.download-job-bar.indeterminate>i{position:absolute;top:0;width:35%;animation:download-scan 1.1s ease-in-out infinite}
@keyframes download-scan{0%{left:-35%}100%{left:100%}}
#download-status .action-icon{flex-shrink:0;background:#26262f;border-color:#3a3a48}
@media(max-width:600px){
 :root{--nav-h:112px}
 /* env(safe-area-inset-top) here is what clears the iOS status bar/notch
    when the app runs installed (standalone display-mode, no browser chrome
    of its own) -- in a normal mobile Safari tab it resolves to 0, so this
    is a no-op there. Dropped by mistake when this rule replaced the base
    nav padding wholesale: on an installed app the top row (logo/aggiorna/
    libreria) rendered flush against, and partly behind, the status bar. */
 nav{display:grid;grid-template-columns:1fr auto auto;height:auto;min-height:calc(112px + env(safe-area-inset-top));gap:10px 8px;padding:calc(12px + env(safe-area-inset-top)) 16px 12px}
 #logo{grid-column:1}#logo em{display:inline;font-size:.65rem}
 #update-btn{grid-column:2;grid-row:1}
 #library-nav{grid-column:3;grid-row:1;margin-left:0;padding:0 11px}#library-nav span{display:none}
 #search-bar{grid-column:1/-1;grid-row:2;width:100%;max-width:none;margin:0;min-height:40px}
 #search-input{font-size:16px}
 .scroll-row .poster-card{flex-basis:160px}.poster-info{padding:10px 8px 6px}
 .poster-title{font-size:.82rem}.personal-actions .action-icon{flex-basis:32px;width:32px}
 .library-heading{padding:24px 0 22px}.library-heading h1{font-size:2rem}
 .library-tabs{gap:2px}.library-tab{padding:0 9px;gap:6px;font-size:.75rem}.library-tab svg{width:17px}
 .library-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
 .details-layout{grid-template-columns:1fr}#details-art{height:180px;min-height:0}#details-art img{object-position:center 25%;filter:brightness(.75)}
 .details-copy{padding:25px 22px}#details-title{font-size:1.6rem}
 #player-title-text{font-size:.78rem}#player-header{gap:8px}#download-btn span{display:none}#download-btn{max-width:none;min-width:38px;padding:0 9px}
}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
