/* HK1 mobile header compatibility only. Preserve frozen skins and all desktop rules.
   Repeated header class specificity is intentional: existing new-site overrides
   use !important. No global overflow masking, copied template, or UA branch. */
@media (max-width: 960px) {
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header {
    --mobile-header-scale: 1;
    --mobile-header-unit: clamp(28px, calc((100vw - 120px) / 5 - 4px), 40px);
    --mobile-header-text-zoom: 1;
    --mobile-header-control: calc(var(--mobile-header-unit) * var(--mobile-header-scale) * var(--mobile-header-text-zoom));
    --mobile-header-font: calc(var(--mobile-header-unit) * var(--mobile-header-scale) * .35);
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) {
    height: auto !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.ds3-head-right,.haoju-global-actions,.iqiyi-actions,.keke-actions) {
    display: flex !important; flex-wrap: nowrap !important; max-width: 100% !important; min-width: 0 !important; height: auto !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .ds3-head.ds3-head {
    display: flex !important; align-items: center !important; flex-wrap: nowrap !important;
    height: auto !important; min-height: 60px !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important;
    padding: calc(10px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left)) !important;
    box-sizing: border-box !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .ds3-head.ds3-head .ds3-head-left {
    display: flex !important; flex: 1 1 0 !important; width: auto !important; min-width: 0 !important;
    position: static !important; inset: auto !important; height: auto !important; overflow: visible !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .ds3-head.ds3-head .ds3-head-right {
    position: static !important; inset: auto !important; display: flex !important;
    flex: 0 0 auto !important; width: auto !important; min-width: 0 !important; max-width: 100% !important;
    gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; margin: 0 0 0 auto !important; align-items: center !important;
    height: auto !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header .haoju-global-head {
    display: grid !important; grid-template-columns: minmax(0,1fr) max-content !important; align-items: center !important;
    width: 100% !important; min-width: 0 !important; max-width: none !important;
    height: auto !important; min-height: 60px !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; margin: 0 !important;
    padding: calc(10px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left)) !important;
    box-sizing: border-box !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header .haoju-global-brand {
    flex: 1 1 88px !important; min-width: 88px !important; max-width: none !important; order: 0 !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header .haoju-global-actions {
    position: static !important; inset: auto !important; flex: 0 0 auto !important;
    width: auto !important; min-width: 0 !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; margin: 0 !important; order: 1 !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header:not(.moviecms-new5-header) .haoju-global-search {
    order: 2 !important; flex: 1 0 100% !important; width: 100% !important; min-width: 0 !important; margin: 4px 0 0 !important;
    grid-column: 1 / -1 !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header.moviecms-new5-header .haoju-global-head {
    grid-template-columns: minmax(0,1fr) max-content max-content !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header.moviecms-new5-header .haoju-global-search {
    flex: 0 0 max(var(--mobile-header-control), 2.8em) !important; order: 0 !important;
    width: max(var(--mobile-header-control), 2.8em) !important; min-width: max(var(--mobile-header-control), 2.8em) !important; max-width: max(var(--mobile-header-control), 2.8em) !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header.moviecms-new5-header .haoju-global-search button {
    width: max(var(--mobile-header-control), 2.8em) !important; min-width: max(var(--mobile-header-control), 2.8em) !important; max-width: max(var(--mobile-header-control), 2.8em) !important;
    height: max(var(--mobile-header-control), 2.8em) !important; min-height: max(var(--mobile-header-control), 2.8em) !important; max-height: max(var(--mobile-header-control), 2.8em) !important;
  }
  html:root body.front.portal.tpl-iqiyi.tpl-iqiyi .iqiyi-header.iqiyi-header .portal-bar {
    display: grid !important; grid-template-columns: max-content minmax(0,1fr) max-content !important; align-items: center !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important;
    width: 100% !important; max-width: none !important; height: auto !important; min-height: 60px !important;
    margin: 0 !important; box-sizing: border-box !important;
    padding: calc(10px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left)) !important;
  }
  html:root body.front.portal.tpl-iqiyi.tpl-iqiyi .iqiyi-header.iqiyi-header .iqiyi-search-form {
    grid-column: 1 / -1 !important; order: 4 !important;
  }
  html:root body.front.portal.tpl-iqiyi.tpl-iqiyi .iqiyi-header.iqiyi-header .iqiyi-brand {
    flex: 1 1 88px !important; min-width: 88px !important; max-width: none !important; margin: 0 !important;
  }
  html:root body.front.portal.tpl-iqiyi.tpl-iqiyi .iqiyi-header.iqiyi-header .iqiyi-actions {
    flex: 0 0 auto !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; margin: 0 !important;
  }
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar {
    display: grid !important; grid-template-columns: max-content minmax(0,1fr) max-content max-content !important; align-items: center !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important;
    height: auto !important; min-height: 60px !important; max-height: none !important; box-sizing: border-box !important;
    padding: calc(10px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left)) !important;
  }
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .keke-brand {
    flex: 1 1 88px !important; min-width: 88px !important; max-width: none !important; margin: 0 !important;
  }
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .keke-actions {
    flex: 0 0 auto !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; height: auto !important; margin: 0 !important;
  }
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .keke-search {
    gap: 0 !important;
  }
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .keke-search:not(.is-open) input {
    display: none !important;
  }
  html:root body.front.portal.nunu-download-page .ds3-head.ds3-head {
    position: sticky !important; top: 0 !important;
  }
  html:root body.front.portal.nunu-download-page .nd-main {
    padding-top: 20px !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.ds3-mobile-search,.theme-toggle[data-theme-toggle],.language-switcher,.language-switcher-trigger,.ds3-user,.ds3-menu,.haoju-action-pill,.haoju-action-menu,.iqiyi-menu-toggle,.portal-search-chip,.iqiyi-login,[data-user-chip],.keke-menu,.keke-search,.keke-search button) {
    width: max(var(--mobile-header-control), 2.8em) !important; min-width: max(var(--mobile-header-control), 2.8em) !important; max-width: max(var(--mobile-header-control), 2.8em) !important;
    height: max(var(--mobile-header-control), 2.8em) !important; min-height: max(var(--mobile-header-control), 2.8em) !important; max-height: max(var(--mobile-header-control), 2.8em) !important;
    flex: 0 0 max(var(--mobile-header-control), 2.8em) !important; padding: 0 !important; margin: 0 !important;
    box-sizing: border-box !important; align-items: center !important; justify-content: center !important;
    line-height: 1 !important; font-size: var(--mobile-header-font) !important; text-align: center !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.ds3-logo,.haoju-global-brand,.iqiyi-brand,.keke-brand) {
    display: flex !important; gap: calc(4px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; align-items: center !important; overflow: visible !important;
    width: max-content !important; min-width: 0 !important;
    margin: 0 !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.brand-asset,.brand-mark) {
    width: calc(32px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; height: calc(32px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; min-width: calc(32px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; max-width: calc(32px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important; flex: 0 0 calc(32px * var(--mobile-header-scale) * var(--mobile-header-text-zoom)) !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.haoju-logo-copy,.ds3-logo-heading,.iqiyi-brand > span:last-child,.keke-brand > span) {
    margin: 0 !important; width: auto !important; min-width: 0 !important; line-height: 1.25 !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.ds3-logo,.haoju-global-brand,.iqiyi-brand,.keke-brand) strong {
    font-size: calc(clamp(14px, 4.4vw, 18px) * var(--mobile-header-scale)) !important; line-height: 1.25 !important; white-space: nowrap !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.ds3-menu,.haoju-action-menu,.iqiyi-menu-toggle,.keke-menu) {
    display: inline-flex !important; flex-direction: column !important; gap: calc(var(--mobile-header-control) * .1) !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is(.ds3-menu,.haoju-action-menu,.iqiyi-menu-toggle,.keke-menu) > span {
    display: block !important; position: static !important; width: calc(var(--mobile-header-control) * .45) !important; height: calc(var(--mobile-header-control) * .05) !important;
    flex: 0 0 calc(var(--mobile-header-control) * .05) !important; margin: 0 !important; background: currentColor !important; border: 0 !important; border-radius: 1px !important; transform: none !important;
  }
  html:root body.front.portal.tpl-haoju.tpl-haoju .haoju-global-header.haoju-global-header .theme-toggle :is(.theme-icon,.theme-switch),
  html:root body.front.portal.tpl-haoju.tpl-haoju .ds3-head.ds3-head .theme-label,
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .theme-label {
    display: none !important;
  }
  html:root body.front.portal:is(.tpl-haoju,.tpl-keke,.tpl-iqiyi):is(.tpl-haoju,.tpl-keke,.tpl-iqiyi) header:is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar):is(.ds3-head,.haoju-global-header,.iqiyi-header,.keke-topbar) :is([data-theme-toggle] .theme-label,.language-switcher-trigger .language-switcher-current) {
    font-size: inherit !important; line-height: inherit !important; white-space: nowrap !important;
  }
}
@media (min-width: 901px) and (max-width: 960px) {
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar {
    grid-template-columns: max-content minmax(0,1fr) max-content !important;
  }
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .keke-search.keke-search {
    order: 2 !important; flex: 1 0 100% !important; width: 100% !important; max-width: 100% !important;
    position: static !important; inset: auto !important; display: flex !important;
    grid-column: 1 / -1 !important;
  }
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .keke-search:not(.is-open) input {
    display: block !important; flex: 1 1 0 !important; min-width: 0 !important;
  }
}
@media (max-width: 900px) {
  html:root body.front.portal.tpl-keke.tpl-keke .keke-topbar.keke-topbar .keke-search.keke-search button {
    font-size: 0 !important;
  }
}
